Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
 public SettingView()
 {
     this.IsNew   = true;
     this.Setting = new YSetting
     {
         Id          = Guid.NewGuid(),
         SettingType = YSettingType.Text
     };
 }
Exemplo n.º 3
0
        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;
 }
Exemplo n.º 5
0
 public SettingView(YSetting setting)
 {
     this.IsNew   = false;
     this.Setting = setting;
 }