Exemple #1
0
 public IActionResult Put(FornecedorEdicaoModel model)
 {
     try
     {
         fornecedorApplicationService.Update(model);
         return(Ok("Fornecedor atualizado com sucesso."));
     }
     catch (Exception e)
     {
         return(StatusCode(500, e.Message));
     }
 }
        public async Task <IActionResult> Put(UpdateFornecedorCommand command)
        {
            try
            {
                await fornecedorApplicationService.Update(command);

                return(Ok(new { Message = "Fornecedor atualizado com sucesso." }));
            }
            catch (ValidationException e)
            {
                return(BadRequest(ValidationAdapter.Parse(e.Errors)));
            }
            catch (Exception e)
            {
                return(StatusCode(500, e.Message));
            }
        }
        public async Task <IActionResult> Edit(Guid id, FornecedorViewModel fornecedor)
        {
            if (!ModelState.IsValid)
            {
                NotifyModelStateErrors();
                return(View(fornecedor));
            }

            var commandResult = await _fornecedorApplicationService.Update(fornecedor);

            if (commandResult.Success)
            {
                NotifyCommandResultSuccess();
                return(RedirectToAction(nameof(Details), new { id = fornecedor.Id }));
            }
            else
            {
                NotifyCommandResultErrors(commandResult.Errors);
            }

            return(View(fornecedor));
        }