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