public ActionResult Editar(int?id, ToDoViewModel toDoViewModel) { if (ModelState.IsValid) { var toDo = Mapper.Map <ToDoViewModel, ToDo>(toDoViewModel); toDo.UpdateDate = DateTime.Now; _toDoAppService.Update(toDo); return(RedirectToAction("index")); } return(PartialView(toDoViewModel)); }
public Results.GenericResult Put(int id, [FromBody] ToDoDto model) { var result = new Results.GenericResult(); var validatorResult = validator.Validate(model); if (validatorResult.IsValid) { try { result.Success = appService.Update(model); if (!result.Success) { throw new Exception($"Todo {id} can't be updated"); } } catch (Exception ex) { result.Errors = new string[] { ex.Message }; } } else { result.Errors = validatorResult.GetErrors(); } return(result); }
public async Task <IActionResult> Update([FromBody] UpdateToDoRequest request) { try { var result = await _appService.Update(request); return(Response(result)); } catch (Exception ex) { _logger.LogError("ERROR: {message}", ex.Message); return(BadRequest(ex)); } }
public bool Put(int id, [FromBody] ToDoDTO model) { return(_appService.Update(model)); }