File tree Expand file tree Collapse file tree 4 files changed +26
-5
lines changed
LibraryManagement.Api/Brokers/Storages Expand file tree Collapse file tree 4 files changed +26
-5
lines changed Original file line number Diff line number Diff line change 33// Free To Use To Build Reliable Library Management Solutions
44//-----------------------------------------------------------
55
6- using LibraryManagement . Api . Models . Foundations . ReaderBooks ;
7- using Microsoft . EntityFrameworkCore ;
6+ using LibraryManagement . Api . Models . Foundations . Books ;
87
98namespace LibraryManagement . Api . Brokers . Storages
109{
11- public partial class StorageBroker
10+ public partial interface IStorageBroker
1211 {
13- public DbSet < ReaderBook > ReaderBooks { get ; set ; }
12+ ValueTask < Book > InsertBookAsync ( Book book ) ;
1413 }
1514}
Original file line number Diff line number Diff line change 1+ //-----------------------------------------------------------
2+ // Copyright (c) Coalition of Good-Hearted Engineers
3+ // Free To Use To Build Reliable Library Management Solutions
4+ //-----------------------------------------------------------
5+
6+ namespace LibraryManagement . Api . Brokers . Storages
7+ {
8+ public partial interface IStorageBroker
9+ { }
10+ }
Original file line number Diff line number Diff line change @@ -11,5 +11,8 @@ namespace LibraryManagement.Api.Brokers.Storages
1111 public partial class StorageBroker
1212 {
1313 public DbSet < Book > Books { get ; set ; }
14+
15+ public async ValueTask < Book > InsertBookAsync ( Book book ) =>
16+ await InsertAsync ( book ) ;
1417 }
1518}
Original file line number Diff line number Diff line change 99
1010namespace LibraryManagement . Api . Brokers . Storages
1111{
12- public partial class StorageBroker : EFxceptionsContext
12+ public partial class StorageBroker : EFxceptionsContext , IStorageBroker
1313 {
1414 private readonly IConfiguration configuration ;
1515
@@ -19,6 +19,15 @@ public StorageBroker(IConfiguration configuration)
1919 this . Database . Migrate ( ) ;
2020 }
2121
22+ public async ValueTask < T > InsertAsync < T > ( T @object )
23+ {
24+ var broker = new StorageBroker ( this . configuration ) ;
25+ broker . Entry ( @object ) . State = EntityState . Added ;
26+ await broker . SaveChangesAsync ( ) ;
27+
28+ return @object ;
29+ }
30+
2231 protected override void OnConfiguring ( DbContextOptionsBuilder optionsBuilder )
2332 {
2433 string connectionString =
You can’t perform that action at this time.
0 commit comments