예제 #1
0
        public void PostSetting(int id, string settingName, [FromBody] string settingValue)
        {
            if (id != 0 && id != permissionContext.LoggedUserId)
            {
                throw new HttpForbiddenException();
            }

            IUserSetting setting = null;

            switch (settingName.ToLowerInvariant())
            {
            case "languagepreference":
                setting = permissionContext.LanguagePreferenceSetting;
                break;
            }

            if (setting == null)
            {
                throw new HttpBadRequestException();
            }

            setting.ParseFromValue(settingValue);

            if (permissionContext.IsLoggedIn)
            {
                queries.UpdateUserSetting(setting);
            }
        }
예제 #2
0
        public IActionResult PostSetting(int id, string settingName, [FromBody] string settingValue)
        {
            if (id != 0 && id != _permissionContext.LoggedUserId)
            {
                return(Forbid());
            }

            IUserSetting setting = null;

            switch (settingName.ToLowerInvariant())
            {
            case "languagepreference":
                setting = _permissionContext.LanguagePreferenceSetting;
                break;
            }

            if (setting == null)
            {
                return(BadRequest());
            }

            setting.ParseFromValue(settingValue);

            if (_permissionContext.IsLoggedIn)
            {
                _queries.UpdateUserSetting(setting);
            }

            return(NoContent());
        }