public IHttpActionResult Post(CreateColorViewModel colormodel) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _service.Create(_mapper.Map <Persistence.KnnProject.Models.Color>(colormodel)); return(Ok()); }
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)); }