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