コード例 #1
0
 public IHttpActionResult Post(CreateColorViewModel colormodel)
 {
     if (!ModelState.IsValid)
     {
         return(BadRequest(ModelState));
     }
     _service.Create(_mapper.Map <Persistence.KnnProject.Models.Color>(colormodel));
     return(Ok());
 }
コード例 #2
0
        public async Task <IActionResult> CreateColor(CreateColorViewModel createColorViewModel)
        {
            if (!ModelState.IsValid)
            {
                return(View(createColorViewModel));
            }

            var colorDto = _mapper.Map <ColorDTO>(createColorViewModel);
            await _colorService.AddAsync(colorDto);

            await _colorService.SaveChangesAsync();

            return(RedirectToAction(nameof(GetColorList), CURRENT_CONTROLLER_NAME));
        }