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")); }
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()); }
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); } }
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)); }
public async Task <IActionResult> DeleteConfirmedAsync(Guid guid) { try { await _iIngredientRepository.Delete(guid); return(Ok()); } catch (Exception) { return(BadRequest()); } }
public ActionResult <Ingredient> Delete(int id) { var content = _contentRepository.Get(id); if (content == null) { return(NotFound()); } else { _contentRepository.Delete(content.Id); return(content); } }
//[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()); }
//[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)); }
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); } }
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")); } }
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; }
public void DeleteIngredient(int ingredientId) { var ingredient = ingredientRepository.GetBy(ingredientId); ingredientRepository.Delete(ingredient); }
public ActionResult Delete(Guid id) { ingredientRepository.Delete(id); return(RedirectToAction("GetAllIngredients")); }
public async Task <IActionResult> DeleteConfirmed(Guid id) { Ingredient ingredient = await _ingredientRepo.Delete(id); return(RedirectToAction(nameof(Index))); }
public async Task <IngredientLogic> Delete(int id) { return(_mapper.Map <IngredientLogic>(await _ingredientRepository.Delete(id))); }
public void DeleteIngredient(Ingredient ingredient) { _ingredientRepo.Delete(ingredient); }
public async Task DeleteIngredient(Guid id) { await _repository.Delete(id); }
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); }
public void Delete() { repository.Delete(Model.Id); }
public bool Delete(int id) { return(ingredientRepository.Delete(id)); }