Beispiel #1
0
        public async Task <ActionResult <bool> > ChangeTheme([FromBody] ThemeModel theme)
        {
            try
            {
                var token  = ExtractHeader(HttpContext, "Authorization", ',', 1);
                var claims = new List <BusinessModels.UserAccessControl.UserClaimModel>();
                claims.Add(new BusinessModels.UserAccessControl.UserClaimModel("Id", theme.id.ToString()));

                var accessPolicy = _authorizationPolicyManager.ConfigureCustomPolicy(new List <string>()
                {
                    "account.theme:change"
                }, claims);
                return(await _userAccountSettingsService.ChangeThemeColorAsync(theme.id, theme.theme));
            }
            catch
            {
                return(false);
            }
        }
Beispiel #2
0
        public async Task <ActionResult <ThemeModel> > GetTheme([FromBody] string id)
        {
            try
            {
                var token  = ExtractHeader(HttpContext, "Authorization", ',', 1);
                var claims = new List <BusinessModels.UserAccessControl.UserClaimModel>();
                claims.Add(new BusinessModels.UserAccessControl.UserClaimModel("Id", id.ToString()));

                var accessPolicy = _authorizationPolicyManager.ConfigureCustomPolicy(new List <string>()
                {
                    "account.theme:get"
                }, claims);
                ThemeModel themeModel = new ThemeModel();
                themeModel.theme = await _userAccountSettingsRepository.GetThemeColorByID(Int32.Parse(id));

                return(themeModel);
            }


            catch
            {
                return(StatusCode(404));
            }
        }