public async Task <IActionResult> Put(string id, [FromBody] string value) { try { if (string.IsNullOrEmpty(value)) { throw new ParameterNullException(ExceptionMessage.CONFIGURATION_VALUE_CANT_BE_NULL); } var result = (await _configurationDBUnitOfWork.ApplicationConfigurationRepository.FindByAsync(x => x.ID == new Guid(id))).SingleOrDefault(); if (result == null) { throw new ItemNotFoundException(); } else if (result.Values == value) { throw new NoChangesToUpdateException(); } logModel.LogMessage = string.Format("User '{0}' Changed '{1}' App Configurations Key '{2}' Value from '{3}' to '{4}'.", userScopesModel.Name, (await _configurationDBUnitOfWork.IntegratedAppRepository.GetSingleAsync(x => x.ID == result.IntegratedAppID)).ApplicationName, result.Key, result.Values, value); // Logging await _loggingServices.LogAsync(logModel); result.Values = value; _configurationDBUnitOfWork.ApplicationConfigurationRepository.Update(result); await _configurationDBUnitOfWork.SaveAsync(); } catch (Exception ex) { return(new ExceptionResult(ex, _loggingServices)); } return(Ok()); }
public async Task <IActionResult> Put(string id, [FromBody] IntegratedApp value) { try { if (value == null) { throw new ParameterNullException(ExceptionMessage.URL_CONFIGURATION_VALUE_CANT_BE_NULL); } var result = (await _configurationDBUnitOfWork.IntegratedAppRepository.FindByAsync(x => x.ID == new Guid(id))).SingleOrDefault(); if (result == null) { throw new ItemNotFoundException(); } if (result.Integrated == value.Integrated && result.ApplicationURL == value.ApplicationURL) { throw new NoChangesToUpdateException(); } logModel.LogMessage = string.Format("User '{0}' Update App '{1}' Configurations Url from '{2}' to '{3}', Integrated '{4}' to '{5}'.", userScopesModel.Name, value.ApplicationName, result.ApplicationURL, value.ApplicationURL, result.Integrated, value.Integrated); // Logging await _loggingServices.LogAsync(logModel); result.ApplicationURL = value.ApplicationURL; result.Integrated = value.Integrated; _configurationDBUnitOfWork.IntegratedAppRepository.Update(result); await _configurationDBUnitOfWork.SaveAsync(); } catch (Exception ex) { return(new ExceptionResult(ex, _loggingServices)); } return(Ok()); }