public ActionResult Edit(IngredientEditModel ingredientEditModel)
        {
            UpdateIngredient updateIngredient = new UpdateIngredient();
            string           type             = "Update";

            sqlCommand = new SqlCommand();

            sqlCommand = updateIngredient.UpdateIngredientData(ingredientEditModel, type);

            return(RedirectToAction("Index", "Home"));
        }
Esempio n. 2
0
        public async Task UpdateAsync(UpdateIngredient model, IValidator <UpdateIngredient> validator)
        {
            ValidateAndThrow(model, validator);

            var ingredient = _mapper.Map <Ingredient>(model);

            if (ingredient.TaskId.HasValue)
            {
                ingredient.Name = null;
            }
            else
            {
                ingredient.Name = ingredient.Name.Trim();
            }

            ingredient.ModifiedDate = DateTime.UtcNow;

            await _ingredientsRepository.UpdateAsync(ingredient);
        }
Esempio n. 3
0
        public async Task <IActionResult> Update([FromBody] UpdateIngredient dto)
        {
            if (dto == null)
            {
                return(BadRequest());
            }

            try
            {
                dto.UserId = IdentityHelper.GetUserId(User);
            }
            catch (UnauthorizedAccessException)
            {
                return(Unauthorized());
            }

            await _ingredientService.UpdateAsync(dto, _updateValidator);

            return(NoContent());
        }
 public async Task <IActionResult> Update(UpdateIngredient updateIngredient) =>
 (await _updateIngredientHandler.Handle(updateIngredient))
 .Match <IActionResult>(
     result => Ok(),
     erro => BadRequest(erro));