public virtual void Delete(int id) { var temp = FindById(id); if (temp != null) { context.Remove <TEntity>(temp); } }
/// <summary> /// Deletes the hotel /// </summary> /// <param name="id">hotel to be deleted</param> /// <returns></returns> public async Task DeleteHotel(int id) { Hotel hotel = await GetHotel(id); _context.Remove(hotel); await _context.SaveChangesAsync(); }
public void DeleteHotel(int id) { using (var hotelDbContext = new HotelDbContext()) { var hotel = GetHotelById(id); hotelDbContext.Remove(hotel); hotelDbContext.SaveChanges(); } }
public async Task DeleteHotel(int id) { using (var hotelDbContext = new HotelDbContext()) { var deletedHotel = hotelDbContext.Hotels.Find(id); hotelDbContext.Remove(deletedHotel); await hotelDbContext.SaveChangesAsync(); } }