コード例 #1
0
        public IActionResult AddCategory(AddCategoryInputModel input)
        {
            if (!input.IsValid())
            {
                return(BadRequest(input.ValidationMessage));
            }
            var category = _categoryAppService.AddCategory(input);

            return(Created(new Uri($"{Request.Path}/{category.Id}", UriKind.Relative), category));
        }
コード例 #2
0
        public async Task <IActionResult> Add([FromBody] CategoryViewModel categoryViewModel)
        {
            var data = await _categoryAppService.AddCategory(categoryViewModel);

            if (data.ValidationResult.IsValid)
            {
                return(Ok(data));
            }
            return(BadRequest(data));
        }