Skip to content

Commit f253c26

Browse files
Merge pull request #35 from DilmurodDeveloper/users/DilmurodDeveloper/brokers-book-update
BROKERS: Update Book
2 parents 71ded55 + 1cd9d50 commit f253c26

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

LibraryManagement.Api/Brokers/Storages/IStorageBroker.Book.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,6 @@ public partial interface IStorageBroker
1212
ValueTask<Book> InsertBookAsync(Book book);
1313
IQueryable<Book> SelectAllBooks();
1414
ValueTask<Book> SelectBookByIdAsync(Guid bookId);
15+
ValueTask<Book> UpdateBookAsync(Book book);
1516
}
1617
}

LibraryManagement.Api/Brokers/Storages/StorageBroker.Book.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,8 @@ public async ValueTask<Book> SelectBookByIdAsync(Guid bookId)
3030

3131
return await ValueTask.FromResult(readerWithBooks);
3232
}
33+
34+
public async ValueTask<Book> UpdateBookAsync(Book book) =>
35+
await UpdateAsync(book);
3336
}
3437
}

LibraryManagement.Api/Brokers/Storages/StorageBroker.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,15 @@ public IQueryable<T> SelectAll<T>() where T : class
3434
return broker.Set<T>();
3535
}
3636

37+
public async ValueTask<T> UpdateAsync<T>(T @object)
38+
{
39+
var broker = new StorageBroker(configuration);
40+
broker.Entry(@object).State = EntityState.Modified;
41+
await broker.SaveChangesAsync();
42+
43+
return @object;
44+
}
45+
3746
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
3847
{
3948
string connectionString =

0 commit comments

Comments
 (0)