public async Task ReturnedBooking(int id) { Booking booking = await GetBookingByKeyAsync(id); if (booking.Returned == false) { booking.Returned = true; foreach (var bookingItem in booking.BookingItems) { //Item item = await _itemService.GetItemByIdAsync(bookingItem.ItemId); Item item = await _itemService.GetObjectByKeyAsync(bookingItem.ItemId); item.Stock = item.Stock + bookingItem.Quantity; //await _itemService.UpdateItemAsync(item.Id, item); await _itemService.UpdateObjectAsync(item); } await dbService.UpdateObjectAsync(booking); } else { booking.Returned = false; foreach (var bookingItem in booking.BookingItems) { //Item item = await _itemService.GetItemByIdAsync(bookingItem.ItemId); Item item = await _itemService.GetObjectByKeyAsync(bookingItem.ItemId); item.Stock = item.Stock - bookingItem.Quantity; //await _itemService.UpdateItemAsync(item.Id, item); await _itemService.UpdateObjectAsync(item); } await dbService.UpdateObjectAsync(booking); } }
public async Task UpdateItemAsync(int id, Item item) { item.Id = id; await _itemDbService.UpdateObjectAsync(item); }