Пример #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);
        }
Пример #2
0
 public ToDoDTO Post([FromBody] ToDoDTO model)
 {
     return(_appService.Create(model));
 }