public Results.GenericResult <TodoDto> Post([FromBody] TodoDto model) { var result = new Results.GenericResult <TodoDto>(); var validatorResult = validator.Validate(model); if (validatorResult.IsValid) { try { result.Result = appService.Create(model); result.Success = true; } catch (Exception ex) { result.Errors = new string[] { ex.Message }; } } else { result.Errors = validatorResult.GetErrors(); } return(result); }
public IActionResult Post([FromBody] TodoViewModel model) { if (!ModelState.IsValid) { return(BadRequest()); } var todoViewModel = _todoAppService.Create(model); return(Ok(todoViewModel)); }
public IActionResult Create(TodoViewModel model) { var todoViewModel = this.LodingInformations(model); if (!ModelState.IsValid) { return(View(model)); } var todo = _todoAppService.Create(model); TempData["Success"] = "Tarefa adicionada com successo!"; return(RedirectToAction(nameof(Index))); }
public TodoVM Post([FromBody] TodoVM todo) { return(appService.Create(todo)); }