public async Task <IActionResult> Post([FromBody] DetailViewModel viewModel) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } viewModel.Id = await _detailService.CreateAsync(viewModel.ToDto(), Bll.Extensions.DetailExtensions.ToEntity); return(CreatedAtAction(nameof(Get), viewModel)); }
public async Task <IActionResult> Put(int id, [FromBody] DetailViewModel viewModel) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } viewModel.Id = id; await _detailService.UpdateAsync(viewModel.ToDto(), Bll.Extensions.DetailExtensions.ToEntity); return(NoContent()); }