コード例 #1
0
        public IActionResult Update(TruthUpdateCommand command)
        {
            var update = _truthService.Update(command);

            if (update.IsError)
            {
                return(BadRequest(update));
            }
            return(Ok(update));
        }
コード例 #2
0
 public ICommandResult Update(TruthUpdateCommand command)
 {
     try
     {
         var truth = _truthRepository.Read(command.Id);
         truth.Type        = command.Type;
         truth.Description = command.Description;
         _truthRepository.Update(truth);
         var commandResult = new CommandResult("Verdade atualizada com sucesso!", truth, false);
         return(commandResult);
     }
     catch (Exception ex)
     {
         var commandResult = new CommandResult($"{ex.InnerException.Message}", null, true);
         return(commandResult);
     }
 }