public IActionResult DeleteDish(int id, string searchText)
        {
            var dish = _repoDish.Delete(id);

            if (dish != null)
            {
                TempData["StatusMessage"] = $"The Dish '{dish.Name}' was deleted.";
            }
            else
            {
                TempData["StatusMessage"] = "#E#:Unable to find this item to delete.";
            }

            return(RedirectToAction(nameof(IndexDish), new { stringText = searchText }));
        }
        public async Task <ActionResult> Delete(int id)
        {
            Dish dish = _dishRepo.Delete(id);
            await S3ImageService.RemoveFileFromS3(id);

            return(RedirectToAction(nameof(IndexPartner), dish));
        }
Beispiel #3
0
        public void DeleteDish(int id)
        {
            var Dish = DishRepository.GetById(id);

            DishRepository.Delete(Dish);
            unitOfWork.Commit();
        }
Beispiel #4
0
        public async Task <BaseResponse> DeleteDish(string id)
        {
            BaseResponse response = new BaseResponse();

            try
            {
                var dish = await _dishRepository.Get(ObjectId.Parse(id));

                if (dish == null)
                {
                    response.SetError(ErrorMessage.RecordNotFound);
                    return(response);
                }
                await _dishRepository.Delete(dish.Id);
            }
            catch (TimeoutException)
            {
                response.SetError(ErrorMessage.TimeoutError);
            }
            catch (FormatException)
            {
                response.SetError(ErrorMessage.FormatError);
            }
            catch (Exception ex)
            {
                response.SetError(ex);
            }
            return(response);
        }
        public ActionResult DeleteConfirmed(int id, string photo)
        {
            string directoryToDelete = Server.MapPath(Url.Content("~/Content/Images"));

            ImageFiles.DeleteFile(directoryToDelete, photo);

            dishRepository.Delete(id);
            return(RedirectToAction("Index"));
        }
        public void DeleteDish(Dish dish)
        {
            List <Ingredient> ingredients = GetIngredientsByDishId(dish.Id);

            foreach (Ingredient ingredient in ingredients)
            {
                DeleteIngredient(ingredient);
            }
            _dishRepo.Delete(dish);
        }
Beispiel #7
0
        public async Task Delete(int?id)
        {
            var productEntity = await _dishRepository.Get(id.Value);

            if (productEntity is null)
            {
                return;
            }

            await _dishRepository.Delete(productEntity);
        }
Beispiel #8
0
        public async Task DeleteAsync(int id)
        {
            var realItem = await _dishRepository.Get(id);

            if (realItem == null)
            {
                throw new NotFoundException();
            }

            await _dishRepository.Delete(id);
        }
Beispiel #9
0
        public bool RemoveProgramDishById(int id)
        {
            var dish = _dishRepository.Find(id);

            if (dish != null)
            {
                _dishRepository.Delete(dish);
                _dishRepository.Save();
                return(true);
            }
            return(false);
        }
Beispiel #10
0
        public async Task <IActionResult> Delete(string collection, string name)
        {
            var dishFromDb = await _dishRepository.GetDish(collection, name);

            if (dishFromDb == null)
            {
                return(new NotFoundResult());
            }
            await _dishRepository.Delete(collection, name);

            return(new OkResult());
        }
        public async Task <DishResponseModel> Handle(DeleteDishCommand request, CancellationToken cancellationToken)
        {
            var existedDish = await _dishRepository.GetByIdAsync(request.Id);

            if (existedDish == null)
            {
                throw new Exception($"Dish with id {request.Id} does not exist");
            }

            await _dishRepository.Delete(existedDish);

            var response = existedDish.Adapt <DishResponseModel>();

            return(response);
        }
Beispiel #12
0
        static void RemoveDish(IDishRepository dishRepository)
        {
            Console.WriteLine("Usuwanie wpisu");

            PrintAllDishes(dishRepository.GetAll());

            Console.Write("\n\nPodaj ID dania do usunięcia: ");
            int idDish;

            while (!int.TryParse(Console.ReadLine(), out idDish))
            {
                Console.Write("Podaj poprawny ID: ");
            }

            dishRepository.Delete(idDish);
        }
Beispiel #13
0
        public IActionResult Delete(int id)
        {
            try
            {
                var selectedDish = _repository.GetDishById(id);
                if (selectedDish == null)
                {
                    return(NotFound());
                }

                _repository.Delete(selectedDish);

                if (_repository.Save())
                {
                    return(Ok());
                }
            }
            catch (Exception)
            {
                return(this.StatusCode(StatusCodes.Status500InternalServerError, "Database Failure"));
            }

            return(BadRequest("Failed to delete the studio"));
        }
Beispiel #14
0
            public async Task <ResponseWrapper <Delete> > Handle(Command request, CancellationToken cancellationToken)
            {
                try
                {
                    var dish = await _context.Get(request.Id);

                    if (dish == null)
                    {
                        throw new RestException(HttpStatusCode.NotFound, "No dish found with this Id");
                    }

                    await _context.Delete(request.Id);

                    _logger.LogInformation("Successfully deleted the dish");
                    var responseWrapper = ResponseWrapper <Delete> .GetInstance((int)HttpStatusCode.OK, null, true, null);

                    return(responseWrapper);
                }
                catch (Exception ex)
                {
                    _logger.LogError(ex, "Problem deleting the dish");
                    throw new Exception("Problem deleting the dish");
                }
            }
Beispiel #15
0
 public void Delete(int id)
 {
     dishRepository.Delete(id);
 }
Beispiel #16
0
        public async Task Delete(Guid id)
        {
            var dish = await _repository.GetById(id);

            await _repository.Delete(dish);
        }
Beispiel #17
0
 public bool Delete(int id)
 {
     return(dishRepository.Delete(id));
 }