예제 #1
0
        /// <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();
        }
예제 #2
0
        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();
        }
예제 #4
0
        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();
        }
예제 #5
0
        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);
            }
        }
예제 #7
0
        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();
        }
예제 #8
0
 public void Delete(T entity)
 {
     _context.Remove(entity);
 }
예제 #9
0
 public IActionResult Delete(Reservation r)
 {
     _context.Remove(r);
     _context.SaveChanges();
     return(RedirectToAction("Details"));
 }