public ActionResult Edit(UserProfileIndexModel model) { model.BaseViewModelInfo.Title = Resources.Account.AccountResources.UserProfile; if (this.RequestType() == HttpVerbs.Get) { DataResultUserProfile userProfileResult = this.ProviderProfile.Get(); model.UserProfileResult = userProfileResult; return View(model); } else { if (ModelState.IsValid) { // Set Culture & Theme values currently in use model.UserProfileResult.Data.CultureName = MvcApplication.UserRequest.UserProfile.CultureName; model.UserProfileResult.Data.Theme = MvcApplication.UserRequest.UserProfile.Theme; DataResultUserProfile result = this.ProviderProfile.Update(model.UserProfileResult.Data); model.UserProfileResultUpdated = result; MvcApplication.UserRequest.UserProfile = result.Data; MvcApplication.UserRequest.UserProfile.ApplyClientProperties(); model.BaseViewModelInfo.LocalizationResources = new LocalizationResourcesHelper(MvcApplication.UserRequest.UserProfile.Culture); } return View(model); } }
public async Task <ActionResult> Index(UserProfileIndexModel model) { if (ModelState.IsValid) { foreach (var kvp in model.FeatureFlags) { var featureFlag = Enum.GetValues(typeof(FeatureFlags)).Cast <FeatureFlags>() .Single(ff => typeof(FeatureFlags).GetField(Enum.GetName(typeof(FeatureFlags), ff)) .GetCustomAttributes(false) .OfType <DisplayAttribute>() .Single().Name == kvp.Key); await this.featureFlagManager.SetFeatureFlagForCurrentUser(featureFlag, kvp.Value); } } return(RedirectToAction("Index")); }
// GET: UserProfile public async Task <ActionResult> Index() { try { var user = await this.aadClient.GetCurrentUser(); var model = new UserProfileIndexModel { DisplayName = user.DisplayName, GivenName = user.GivenName, Surname = user.Surname }; foreach (var featureFlag in Enum.GetValues(typeof(FeatureFlags)).Cast <FeatureFlags>()) { model.FeatureFlags.Add( typeof(FeatureFlags).GetField(Enum.GetName(typeof(FeatureFlags), featureFlag)) .GetCustomAttributes(false) .OfType <DisplayAttribute>() .Single().Name, await featureFlagManager.IsFeatureFlagEnabledForCurrentUser(featureFlag)); } return(View(model)); } catch (AdalException) { // Return to error page. return(View("Error")); } // if the above failed, the user needs to explicitly re-authenticate for the app to obtain the required token catch (Exception) { return(View("Relogin")); } }
public ActionResult Index(UserProfileIndexModel model) { model.BaseViewModelInfo.Title = Resources.Account.AccountResources.UserProfile; model.UserProfileResult = this.ProviderProfile.Get(); return View(model); }