public async Task <ActionResult <YSetting> > SaveSettingAsync(Guid id, [FromBody] YSetting setting) { HttpContext.VerifyUserHasAnyAcceptedScope(scopeRequiredByApi); var userObjectId = this.User.GetObjectId(); if (string.IsNullOrEmpty(userObjectId)) { return(new UnauthorizedObjectResult("User unknown")); } if (!this.User.IsInRole("Admin")) { return(new UnauthorizedObjectResult("You should be admin for this action")); } if (id != setting.Id) { return(new UnprocessableEntityObjectResult("id and entity differs")); } var itemSaved = await this.settingProvider.SaveSettingAsync(setting); return(itemSaved); }
public SettingView() { this.IsNew = true; this.Setting = new YSetting { Id = Guid.NewGuid(), SettingType = YSettingType.Text }; }
public async Task <YSetting> SaveSettingAsync(YSetting setting) { using CosmosClient client = new CosmosClient(accountEndpoint, accountKey, clientOptions); var container = client.GetContainer(databaseName, containerName); setting.UpdateDate = DateTime.Now; ItemResponse <YSetting> response = await container.UpsertItemAsync(setting, partitionKey).ConfigureAwait(false); return(setting); }
public Sample(YSetting ySetting) { SampleValueX = 0; SampleValueY = ySetting.Y; SampleFacing = ySetting.SampleFacing; }
public SettingView(YSetting setting) { this.IsNew = false; this.Setting = setting; }