コード例 #1
0
        public async Task <IActionResult> CreateColor([FromForm] CreateStyleDTO createStyleDTO)
        {
            var duplicateStyle = _styleService.FindByNameAsync(createStyleDTO.Name);

            if (duplicateStyle.Result != null)
            {
                return(BadRequest(new { Name = "This style name already exists" }));
            }
            var style = _mapper.Map <Style>(createStyleDTO);
            await _styleService.CreateAsync(style);

            return(NoContent());
        }