/// <summary> /// Delete product from menu table /// </summary> /// <param name="id"></param> public void DeleteMenuContent(int id) { var menuContent = _context.Set <Menu>().FirstOrDefault(x => x.MenuId == id); _context.Remove(menuContent); _context.SaveChanges(); }
public async Task DeleteAsync(int id) { Restaurant restaurant = await _context.Restaurants.FindAsync(id); if (restaurant != null) { _context.Remove(restaurant); await _context.SaveChangesAsync(); } }
public async Task DeleteSheesha(Guid id) { var sheesha = await _context.Sheeshas.SingleOrDefaultAsync(s => s.Id == id); if (sheesha == null) { return; } _context.Remove(sheesha); await _context.SaveChangesAsync(); }
public void RemoveById(int dishId) { var dish = _dbContext.Dishes.FirstOrDefault(d => d.Id == dishId); if (dish is null) { throw new NotFoundException("Dish not found"); } _dbContext.Remove(dish); _dbContext.SaveChanges(); }
public void RemoveById(int restaurantId, int dishId) { var restaurant = GetRestaurantById(restaurantId); var dish = restaurant.Dishes.FirstOrDefault(d => d.Id == dishId); if (dish is null) { throw new NotFoundException("Restaurant was not found"); } _dbContext.Remove(dish); _dbContext.SaveChanges(); return; }
public void Delete(Restaurant resto) { var data = GetById(resto.Id); try { _db.Remove(data); _db.SaveChanges(); } catch (Exception ex) { throw new Exception(ex.Message); } }
public void RemoveById(int restaurantId, int dishId) { var restaurant = GetRestaurantById(restaurantId); var dish = _context.Dishes.FirstOrDefault(d => d.Id == dishId); if (dish is null || dish.RestaurantId != restaurantId) { throw new NotFoundException("Dish not found"); } _context.Remove(dish); _context.SaveChanges(); }
public void Delete(T entity) { _context.Remove(entity); }
public IActionResult Delete(Reservation r) { _context.Remove(r); _context.SaveChanges(); return(RedirectToAction("Details")); }