public async Task <bool> UpdateBike(BikeViewModel model) { if (model != null) { var bike = new BicycleInventory { BikeId = model.BikeId, ModelNo = model.ModelNo, Brand = model.Brand, Status = model.Status, BicycleType = await _context.BicycleTypes.FindAsync(model.SelectBikeTypeId) }; var current = await _context.BicycleInventories.FindAsync(model.BikeId); _context.Entry(current).CurrentValues.SetValues(bike); await _context.SaveChangesAsync(); return(true); } return(false); }
public async Task <bool> UpdateCustomer(CustomerViewModel model) { if (model != null) { var customer = new Customer { CustomerId = model.CustomerId, FirstName = model.FirstName, LastName = model.LastName, Address = model.Address, Status = model.Status, BirthDate = model.BirthDate }; var current = await _context.Customers.FindAsync(model.CustomerId); _context.Entry(current).CurrentValues.SetValues(customer); await _context.SaveChangesAsync(); return(true); } return(false); }
public async Task <bool> UpdateBooking(BikeBookingViewModel model) { if (model != null) { var booking = new BicycleBooking { RentalId = model.RentalId, RentedDate = model.RentedDate, ReturnedDate = model.ReturnedDate, BicycleInventory = await _context.BicycleInventories.FindAsync(model.SelectedBikeId), Customer = await _context.Customers.FindAsync(model.SelectedCustomerId), ModifiedBy = model.ModifiedBy, ModifiedDate = model.ModifiedDate }; var current = await _context.BicycleRentals.FindAsync(model.RentalId); _context.Entry(current).CurrentValues.SetValues(booking); await _context.SaveChangesAsync(); return(true); } return(false); }