public void Add <T>(T entity) where T : class { try { _context.Add(entity); _context.SaveChangesAsync(); } catch (Exception ex) { throw ex; } }
public async Task <string> DeallocateBoat(Boat_RentInfo model) { try { var boatInfo = _context.Boat_RentInfo.Include(b => b.Boat_Info).Where(x => x.BoatId != model.BoatId && model.ReturnedStatus == false).FirstOrDefault(); if (boatInfo == null) { return("Only rented out boats can be returned"); } else { boatInfo.ReturnedStatus = true; } await _context.SaveChangesAsync(); double rentTime = (DateTime.Now - boatInfo.CreatedOn).TotalHours; return($"Rent time: {rentTime}, Amount to be paid: {rentTime * model.Boat_Info.HourlyRate}"); } catch (Exception ex) { throw ex; } }