public async Task <ActionResult> Store([FromBody] ManualViewModel model) { ValidateRequest(model); if (!ModelState.IsValid) { return(BadRequest(ModelState)); } model.Order = model.Active ? 0 : -1; var manual = model.MapEntity(_mapper, CurrentUserId); manual = await _manualsService.CreateAsync(manual); return(Ok(manual.Id)); }
public async Task <ActionResult> Update(int id, [FromBody] ManualViewModel model) { var existingEntity = await _manualsService.GetByIdAsync(id); if (existingEntity == null) { return(NotFound()); } ValidateRequest(model); if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var notice = model.MapEntity(_mapper, CurrentUserId); notice.Order = model.Active ? 0 : -1; await _manualsService.UpdateAsync(existingEntity, notice); return(Ok()); }