public void Update(UpdateDutyDto dto) { var duty = _dutyRepository.GetById(dto.Id); if (duty != null) { duty.Title = dto.Title; duty.ActionLimitDays = dto.ActionLimitDays; _dutyRepository.Update(duty); } else { try { throw new LogicalException(); } catch (LogicalException ex) { _logger.LogLogicalError (ex, "Duty entity with the id: '{0}', is not available." + " update operation failed.", dto.Id); throw; } } }
public IHttpActionResult Update([FromBody] UpdateDutyDto duty) { if (duty == null) { return(BadRequest()); } if (!ModelState.IsValid) { string errorMessage = new ModelStateError(_logger).OutputMessage(ModelState); return(BadRequest(errorMessage)); } try { _dutyService.Update(duty); } catch (LogicalException ex) { return(BadRequest(ex.Message)); } catch { return(BadRequest(AppSettings.INTERNAL_SERVER_ERROR_MESSAGE)); } return(Ok()); }