public async Task <ActionResult> Store([FromBody] SubjectViewModel model) { await ValidateRequestAsync(model); if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var subject = model.MapEntity(_mapper, CurrentUserId); subject = await _subjectsService.CreateAsync(subject); return(Ok(subject.Id)); }
public async Task <ActionResult> Update(int id, [FromBody] SubjectViewModel model) { var existingEntity = _subjectsService.GetById(id); if (existingEntity == null) { return(NotFound()); } await ValidateRequestAsync(model); if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var subject = model.MapEntity(_mapper, CurrentUserId); await _subjectsService.UpdateAsync(existingEntity, subject); return(Ok()); }