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