public ActionResult Edit(StoreUser storeUserNew)
        {
            if (ModelState.IsValid)
            {
                var give = new List<string>();
                var take = new List<string>();

                var storeUserOld = StoreUserFromUsername(storeUserNew.userName);
                if(storeUserOld.recordLabel != storeUserNew.recordLabel)
                {
                    if (storeUserOld.recordLabel != null)
                    {
                        take.Add(GroupNameToRoleName(storeUserOld.recordLabel));
                    }
                    if(storeUserNew.recordLabel != null)
                    {
                        give.Add(GroupNameToRoleName(storeUserNew.recordLabel));
                    }
                }
                if(storeUserOld.isManager != storeUserNew.isManager)
                {
                    if(storeUserNew.isManager)
                    {
                        give.Add(managerRoleName);
                    }
                    else
                    {
                        take.Add(managerRoleName);
                    }
                }

                string[] takeRoles = take.ToArray();
                string[] giveRoles = give.ToArray();

                if(takeRoles.Length > 0)
                {
                    Roles.RemoveUserFromRoles(storeUserNew.userName, takeRoles);
                }
                if(giveRoles.Length > 0)
                {
                    Roles.AddUserToRoles(storeUserNew.userName, giveRoles);
                }
                return RedirectToAction("Index");
            }
            ViewBag.RecordLabel = new SelectList(GroupsList(), storeUserNew.recordLabel);
            return View(storeUserNew);
        }
 private StoreUser StoreUserFromUsername(string username)
 {
     var storeUser = new StoreUser();
     storeUser.userName = username;
     foreach (var role in Roles.GetRolesForUser(username))
     {
         if (role.StartsWith(designator))
         {
             storeUser.recordLabel = RoleNameToGroupName(role);
         }
         else if(role == managerRoleName)
         {
             storeUser.isManager = true;
         }
     }
     return storeUser;
 }