11using System ;
2+ using Azure . Data . Tables ;
3+ using Azure . Storage . Blobs ;
24using Microsoft . AspNetCore . Http . HttpResults ;
35using NoteBookmark . Domain ;
46
@@ -27,10 +29,13 @@ public static void MapNoteEndpoints(this IEndpointRouteBuilder app)
2729 . WithDescription ( "Update the read status of all posts to true if they have a note referencing them." ) ;
2830 }
2931
30- static Results < Created < Note > , BadRequest > CreateNote ( Note note , IDataStorageService dataStorageService )
32+ static Results < Created < Note > , BadRequest > CreateNote ( Note note ,
33+ TableServiceClient tblClient ,
34+ BlobServiceClient blobClient )
3135 {
3236 try
3337 {
38+ var dataStorageService = new DataStorageService ( tblClient , blobClient ) ;
3439 dataStorageService . CreateNote ( note ) ;
3540 var post = dataStorageService . GetPost ( note . PostId ! ) ;
3641 if ( post is not null )
@@ -47,22 +52,31 @@ static Results<Created<Note>, BadRequest> CreateNote(Note note, IDataStorageServ
4752 }
4853 }
4954
50- static Results < Ok < List < Note > > , NotFound > GetNotes ( IDataStorageService dataStorageService )
55+ static Results < Ok < List < Note > > , NotFound > GetNotes ( TableServiceClient tblClient ,
56+ BlobServiceClient blobClient )
5157 {
58+ var dataStorageService = new DataStorageService ( tblClient , blobClient ) ;
5259 var notes = dataStorageService . GetNotes ( ) ;
5360 return notes == null ? TypedResults . NotFound ( ) : TypedResults . Ok ( notes ) ;
5461 }
5562
56- static Results < Ok < List < ReadingNote > > , NotFound > GetNotesForSummary ( string ReadingNotesId , IDataStorageService dataStorageService )
63+ static Results < Ok < List < ReadingNote > > , NotFound > GetNotesForSummary ( string ReadingNotesId ,
64+ TableServiceClient tblClient ,
65+ BlobServiceClient blobClient )
5766 {
67+
68+ var dataStorageService = new DataStorageService ( tblClient , blobClient ) ;
5869 var notes = dataStorageService . GetNotesForSummary ( ReadingNotesId ) ;
5970 return notes == null ? TypedResults . NotFound ( ) : TypedResults . Ok ( notes ) ;
6071 }
6172
62- private static async Task < Results < Created < string > , BadRequest > > SaveReadingNotes ( ReadingNotes readingNotes , IDataStorageService dataStorageService )
73+ private static async Task < Results < Created < string > , BadRequest > > SaveReadingNotes ( ReadingNotes readingNotes ,
74+ TableServiceClient tblClient ,
75+ BlobServiceClient blobClient )
6376 {
6477 try
6578 {
79+ var dataStorageService = new DataStorageService ( tblClient , blobClient ) ;
6680 var url = await dataStorageService . SaveReadingNotes ( readingNotes ) ;
6781 return url == null ? TypedResults . BadRequest ( ) : TypedResults . Created ( "url" , url ) ;
6882 }
@@ -73,10 +87,12 @@ private static async Task<Results<Created<string>, BadRequest>> SaveReadingNotes
7387 }
7488 }
7589
76- private static async Task < Results < Ok , BadRequest > > UpdatePostReadStatus ( IDataStorageService dataStorageService )
90+ private static async Task < Results < Ok , BadRequest > > UpdatePostReadStatus ( TableServiceClient tblClient ,
91+ BlobServiceClient blobClient )
7792 {
7893 try
7994 {
95+ var dataStorageService = new DataStorageService ( tblClient , blobClient ) ;
8096 await dataStorageService . UpdatePostReadStatus ( ) ;
8197 return TypedResults . Ok ( ) ;
8298 }
0 commit comments