예제 #1
0
        public void Delete()
        {
            if (Model.Id != Guid.Empty)
            {
                var delete = _messageDialogService.Show(
                    $"Delete",
                    $"Do you want to delete {Model?.Name}?.",
                    MessageDialogButtonConfiguration.YesNo,
                    MessageDialogResult.No);

                if (delete == MessageDialogResult.No)
                {
                    return;
                }

                try
                {
                    _ingredientRepository.Delete(Model.Id);
                }
                catch
                {
                    var _ = _messageDialogService.Show(
                        $"Deleting of {Model?.Name} failed!",
                        "Deleting failed",
                        MessageDialogButtonConfiguration.OK,
                        MessageDialogResult.OK);
                    return;
                }

                _mediator.Send(new DeleteMessage <IngredientWrapper>
                {
                    Model = Model
                });
            }
        }
        public IActionResult Delete(int id)
        {
            var model = _ingredientRepository.GetIngredient(id);

            _ingredientRepository.Delete(model);
            return(RedirectToAction("Index"));
        }
예제 #3
0
        public IActionResult Remove(Guid foodId, Guid id)
        {
            FoodItem foodItem = _foodRepository.GetSingle(foodId);

            if (foodItem == null)
            {
                return(NotFound("FoodNotFound"));
            }

            var singleItem = _repository.GetAll().Where(x => x.FoodItem.Id == foodId && x.Id == id).FirstOrDefault();

            if (singleItem == null)
            {
                return(NotFound());
            }

            _repository.Delete(id);

            if (!_repository.Save())
            {
                throw new Exception($"Deleting ingredient {id} for food {foodId} failed on save.");
            }

            return(NoContent());
        }
예제 #4
0
 public bool DeleteIngredient(int ingredientId)
 {
     try
     {
         var ingredientToDelete = _ingredientRepository.FindOne(x => x.Id == ingredientId);
         _ingredientRepository.Delete(ingredientToDelete);
         _ingredientRepository.Persist();
         Log.Debug("Ingredient '{0}' with Id '{1}' deleted.", ingredientToDelete.IngredientName, ingredientToDelete.Id);
         return(true);
     }
     catch (Exception e)
     {
         Log.Error(string.Format("Failed to delete ingredient with Id '{0}'", ingredientId), e);
         return(false);
     }
 }
예제 #5
0
        public async Task DeleteAsync(int id)
        {
            var realItem = await _ingredientRepository.Get(id);

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

            await _ingredientRepository.Delete(id);
        }
        public async Task <ActionResult> Delete(int id)
        {
            var isDeleted = await _ingredientRepository.Delete(id);

            if (!isDeleted)
            {
                return(StatusCode(403, new ErrorModel {
                    ErrorMessage = String.Format(ERROR_MESSAGE, id)
                }));
            }

            return(StatusCode(204));
        }
예제 #7
0
        public async Task <IActionResult> DeleteConfirmedAsync(Guid guid)
        {
            try
            {
                await _iIngredientRepository.Delete(guid);

                return(Ok());
            }
            catch (Exception)
            {
                return(BadRequest());
            }
        }
예제 #8
0
        public ActionResult <Ingredient> Delete(int id)
        {
            var content = _contentRepository.Get(id);

            if (content == null)
            {
                return(NotFound());
            }
            else
            {
                _contentRepository.Delete(content.Id);
                return(content);
            }
        }
예제 #9
0
        //[Authorize(Policy = PermissionsList.PermissionsIngredientDelete)]
        public async Task <IActionResult> DeleteIngredient(string id)
        {
            Guid       ingredientId = Guid.Parse(id);
            Ingredient ingredient   = await _ingredientRepository.GetById(ingredientId);

            if (ingredient == null)
            {
                return(NotFound());
            }

            _ingredientRepository.Delete(ingredient);


            return(Ok());
        }
예제 #10
0
        //[Authorize(Policy = PermissionsList.PermissionsIngredientDelete)]
        public Task DeleteIngredient(string id)
        {
            Guid       ingredientId = Guid.Parse(id);
            Ingredient ingredient   = _ingredientRepository.GetById(ingredientId).Result;

            if (ingredient == null)
            {
                var ingredientsOld = _ingredientRepository.GetAll().Result;
                return(Clients.All.SendAsync("GetIngredients", ingredientsOld));
            }

            _ingredientRepository.Delete(ingredient);

            var ingredients = _ingredientRepository.GetAll().Result;

            return(Clients.All.SendAsync("GetIngredients", ingredients));
        }
예제 #11
0
        public void ShouldDeleteIngredient()
        {
            var ingredient = IngredientBuilder.BuildIngredient();

            _ingredientRepository.Add(ingredient);
            _ingredientRepository.Persist();

            _ingredientRepository.Delete(ingredient);
            _ingredientRepository.Persist();
            _ingredientRepository.Find(i => i != null).Count().ShouldEqual(0);

            using (var dataContext = GetNewDataContext())
            {
                var result = dataContext.GetTable <Ingredient>().ToList();
                result.Count.ShouldEqual(0);
            }
        }
예제 #12
0
 public IActionResult DeleteRecipe(int id)
 {
     if (_settings.AllowDelete)
     {
         if (ModelState.IsValid)
         {
             _ingredientRepository.Delete(id);
             _stepsRepository.Delete(id);
             _recipeRepository.Delete(id);
         }
         return(RedirectToAction("Index", "Recipe"));
     }
     else
     {
         return(RedirectToAction("Error", "Home"));
     }
 }
예제 #13
0
        public void Delete()
        {
            if (Model.Id != Guid.Empty)
            {
                try
                {
                    _ingredientRepository.Delete(Model.Id);
                }
                catch
                {
                    _messageBoxService.Show($"Deleting of {Model?.Name} failed!", "Deleting failed", MessageBoxButton.OK);
                }

                _mediator.Send(new IngredientDeletedMessage {
                    Id = Model.Id
                });
            }
            Model = null;
        }
예제 #14
0
        public void DeleteIngredient(int ingredientId)
        {
            var ingredient = ingredientRepository.GetBy(ingredientId);

            ingredientRepository.Delete(ingredient);
        }
예제 #15
0
 public ActionResult Delete(Guid id)
 {
     ingredientRepository.Delete(id);
     return(RedirectToAction("GetAllIngredients"));
 }
예제 #16
0
        public async Task <IActionResult> DeleteConfirmed(Guid id)
        {
            Ingredient ingredient = await _ingredientRepo.Delete(id);

            return(RedirectToAction(nameof(Index)));
        }
예제 #17
0
 public async Task <IngredientLogic> Delete(int id)
 {
     return(_mapper.Map <IngredientLogic>(await _ingredientRepository.Delete(id)));
 }
예제 #18
0
 public void DeleteIngredient(Ingredient ingredient)
 {
     _ingredientRepo.Delete(ingredient);
 }
예제 #19
0
 public async Task DeleteIngredient(Guid id)
 {
     await _repository.Delete(id);
 }
예제 #20
0
 public async Task DeleteIngredient(long selectedIngredientId)
 {
     await _ingredientRepository.Delete(selectedIngredientId);
 }
 public Task <Either <string, Unit> > Handle(DeleteIngredient command) =>
 Validate(command)
 .Match <Task <Either <string, Unit> > >(
     async id => await _ingredientRepository.Delete(id),
     (v) => Task.FromResult(new Either <string, Unit>(v))
     );
 public void Delete(Ingredient entity)
 {
     _ingrerdientRepository.Delete(entity);
 }
예제 #23
0
 public void Delete()
 {
     repository.Delete(Model.Id);
 }
예제 #24
0
 public bool Delete(int id)
 {
     return(ingredientRepository.Delete(id));
 }