public ActionResult Subs(SubListModel model) { // see if any subs were changed foreach (var sub in model.Subscriptions) { if (sub.NewAccessLevel != null && (ulong)sub.NewAccessLevel.Value != sub.AccessLevel) { // attempt to update it try { if (ContentProviderHost.CurrentProvider.UpdatePermissions(GetUserToken(), sub.SubscriptionGuid.ToString(), (ulong)sub.NewAccessLevel)) { model.SuccessMessages.Add("Subscription " + sub.Name + " updated."); sub.AccessLevel = (ulong)sub.NewAccessLevel; } else { model.WarningMessages.Add("Subscription " + sub.Name + " was not updated."); } } catch (Exception ex) { model.ErrorMessages.Add("Subscription " + sub.Name + " encountered an error during update."); model.Exception = ex; break; } } } return(View(model)); }
public ActionResult Subs(string id) { SubListModel model = new SubListModel(); try { // id is the account guid. subscriptions are on the main API, not the auth API var account = AuthProviderHost.PrimaryAuthProvider.GetAccount(GetUserToken(), id); var subs = ContentProviderHost.CurrentProvider.GetSubscriptions(GetUserToken(), id); model.AccountGuid = id; model.AccountName = account.Name; // copy over the default access levels subs.ForEach(m => m.NewAccessLevel = (AccessLevel)m.AccessLevel); model.Subscriptions = subs; } catch (Exception ex) { model.ErrorMessages.Add("Error retrieving data from API(s)"); model.Exception = ex; } return(View(model)); }