fix item update api
All checks were successful
Build and Deploy API / build-and-deploy (push) Successful in 9s
All checks were successful
Build and Deploy API / build-and-deploy (push) Successful in 9s
This commit is contained in:
@@ -31,10 +31,17 @@ public class ItemService {
|
||||
return item;
|
||||
}
|
||||
|
||||
public async Task<Item> Update(Item item) {
|
||||
db_.Items.Update(item);
|
||||
public async Task<Item?> Update(int id, ItemDto item) {
|
||||
|
||||
Item? oldItem = await db_.Items.FindAsync(id);
|
||||
if(oldItem == null) return oldItem;
|
||||
|
||||
oldItem.Name = item.Name;
|
||||
oldItem.Description = item.Description;
|
||||
oldItem.LastEditedAt = DateTime.UtcNow;
|
||||
|
||||
await db_.SaveChangesAsync();
|
||||
return item;
|
||||
return oldItem;
|
||||
}
|
||||
|
||||
public async Task<bool> Delete(int id) {
|
||||
|
||||
Reference in New Issue
Block a user