public async Task <IActionResult> Post([FromBody] AddSpecFieldModel model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var specField = _mapper.Map <SpecField>(model); specField = await _specFieldService.Create(specField); var view = _mapper.Map <SpecFieldModel>(specField); return(Ok(view)); }
public async Task <IActionResult> Put(int id, [FromBody] AddSpecFieldModel model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var specField = await _specFieldService.GetByIdAsync(id); if (specField == null) { return(NotFound()); } specField = _mapper.Map(model, specField); specField = await _specFieldService.Update(specField); var view = _mapper.Map <SpecFieldModel>(specField); return(Ok(view)); }