示例#1
0
        public IActionResult Delete(string id)
        {
            var dish = _dishService.Get(id);

            if (dish != null)
            {
                _dishService.Delete(id);

                return(RedirectToAction("Index"));
            }

            return(NotFound());
        }
示例#2
0
        public HttpResponseMessage Delete(HttpRequestMessage request, int id)
        {
            return(CreateHttpResponse(request, () =>
            {
                HttpResponseMessage response = null;

                if (!ModelState.IsValid)
                {
                    response = request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState);
                }
                else
                {
                    Dish dish = dishService.Delete(id);
                    dishService.SaveChanges();
                    SaveHistory("Add new Dish with ID: " + dish.ID);
                    response = request.CreateResponse(HttpStatusCode.OK, dish);
                }
                return response;
            }));
        }
        public async Task Delete(int?id)
        {
            var restaurantEntity = await _restaurantRepository.Get(id.Value);

            if (restaurantEntity is null)
            {
                return;
            }

            var meals     = restaurantEntity.Meals;
            var employess = restaurantEntity.Employees;

            await _restaurantRepository.Delete(restaurantEntity);

            foreach (Dish dish in meals)
            {
                await _dishService.Delete(dish.Id);
            }

            foreach (User user in employess)
            {
                await _userService.Delete(user.Id);
            }
        }
示例#4
0
        public ActionResult Delete([FromRoute] int id)
        {
            _dishService.Delete(id);

            return(NoContent());
        }
示例#5
0
        public async Task <IActionResult> DeletePOST(int id)
        {
            await _dishService.Delete(id);

            return(RedirectToAction(nameof(Index)));
        }
示例#6
0
 public ActionResult Delete(int id)
 {
     return(Ok(
                dishService.Delete(id)
                ));
 }
示例#7
0
 public ActionResult Delete(Guid id)
 {
     _dishService.Delete(id);
     return(RedirectToAction("Index", "Menu"));
 }
示例#8
0
        public ActionResult Delete([FromRoute] int restaurantId, [FromRoute] int id)
        {
            _service.Delete(restaurantId, id);

            return(NoContent());
        }
示例#9
0
        public async Task <IActionResult> Delete(Guid id)
        {
            await _dishService.Delete(id);

            return(Ok());
        }
示例#10
0
 protected override void ExecuteCommand()
 {
     dishService.Delete(Id);
 }
示例#11
0
 /// <summary>
 /// delete dish
 /// </summary>
 /// <param name="id"></param>
 /// <returns></returns>
 public IActionResult DeleteDish(int id)
 {
     dishService.Delete(id);
     return(RedirectToAction("Dishes"));
 }
示例#12
0
 public RedirectResult Delete(int id)
 {
     _dishService.Delete(id);
     return(Redirect("/Dish/GetAll"));
 }