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 IActionResult Put([FromBody] TodoViewModel model) { if (!ModelState.IsValid) { return(BadRequest()); } var todoViewModel = _todoAppService.Update(model); return(Ok(todoViewModel)); }
public void Put(int id, [FromBody] TodoViewModel value) { try { if (ModelState.IsValid) { value.Id = id; _todoApp.Update(Mapper.Map <TodoViewModel, Todo>(value)); } } catch (Exception ex) { throw ex; } }
public async Task <IActionResult> Put([FromBody] TodoAppViewModel todoAppViewModel) { return(ModelState.IsValid ? CustomResponse(await _todoAppService.Update(todoAppViewModel)) : CustomResponse(todoAppViewModel)); }
public bool Put(int id, [FromBody] TodoVM todo) { return(appService.Update(todo)); }