public void then_update() { var representationPut = new AppSettingPutRp(); representationPut.Value = NewValue; var jsonContent = HttpClientExtension.ParseModelToHttpContent(representationPut); var responsePut = _client.PutAsync($"/appsettings/{representation.Key}", jsonContent).Result; Assert.True(responsePut.IsSuccessStatusCode); }
public async Task UpdateAppSetting(string id, AppSettingPutRp resource) { var appSetting = await this._appSettingDataService.GetById(id); if (appSetting == null) { await _businessManagerService.AddNotFound($"The Id {id} doesn't exists."); return; } appSetting.Value = resource.Value; appSetting.Update(this._identityService.GetUserId()); await this._appSettingDataService.Update(appSetting); await this._appSettingDataService.SaveChanges(); }
/// <summary> /// Update appsetting /// </summary> /// <param name="model">AppSetting Model</param> /// <returns></returns> public async Task <BaseComponentResultRp> UpdateAppSetting(string key, AppSettingPutRp model) { var result = new BaseComponentResultRp(); var appSetting = await this._dbContext.AppSettings.FirstOrDefaultAsync(c => c.Key.Equals(key)); if (appSetting == null) { result.AddNotFound($"The Resource {key} doesn't exists."); return(result); } appSetting.Value = model.Value; appSetting.ModifiedBy = this._identityGateway.GetIdentity(); appSetting.ModifiedOn = DateTime.UtcNow; this._dbContext.Update(appSetting); await this._dbContext.SaveChangesAsync(); return(result); }
public async Task <IActionResult> Put(string id, [FromBody] AppSettingPutRp resource) { if (!this.ModelState.IsValid) { return(this.BadRequest(this.ModelState)); } await this._appSettingService.UpdateAppSetting(id, resource); if (this._businnesManagerService.HasNotFounds()) { return(this.NotFound(this._businnesManagerService.GetNotFounds())); } if (this._businnesManagerService.HasConflicts()) { return(this.Conflict(this._businnesManagerService.GetConflicts())); } return(this.Ok()); }
/// <summary> /// Update appsetting /// </summary> /// <param name="model">AppSetting Model</param> /// <returns></returns> public async Task <BaseComponentResultRp> UpdateAppSetting(string key, AppSettingPutRp model) { var result = new BaseComponentResultRp(); var appSetting = await this._appSettingRepository.GetAppSettingByKey(key); if (appSetting == null) { result.AddNotFound($"The Key {key} doesn't exists."); return(result); } appSetting.Value = model.Value; appSetting.UpdatedBy = this._identityService.GetIdentity(); appSetting.UpdatedOn = DateTime.UtcNow; this._appSettingRepository.Update(appSetting); await this._appSettingRepository.SaveChanges(); return(result); }
public async Task <IActionResult> Put(string id, [FromBody] AppSettingPutRp resource) { if (!this.ModelState.IsValid) { return(this.BadRequest(this.ModelState)); } var response = await this._appSettingComponent.UpdateAppSetting(id, resource); if (response.HasNotFounds()) { return(this.NotFound(response.GetNotFounds())); } if (response.HasConflicts()) { return(this.Conflict(response.GetConflicts())); } return(this.Ok()); }