Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        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)));
        }
Esempio n. 4
0
 public TodoVM Post([FromBody] TodoVM todo)
 {
     return(appService.Create(todo));
 }