public ActionResult EditUser(AdminAddUpdateUserVM model)
        {
            model.AvailableRoles = IdentityPostmaster.SetAvailableRoles();

            if (model.Password != model.PasswordConfirmed)
            {
                ModelState.AddModelError("PasswordConfirmed", "Your password and password confirmation did not match.");
            }
            if (ModelState.IsValid)
            {
                var courier = IdentityPostmaster.PackageUpdateUser(model);

                if (courier.Success)
                {
                    return(RedirectToAction("Users"));
                }
                else
                {
                    ModelState.AddModelError("TargetUserName", courier.Message);

                    return(View(model));
                }
            }
            else
            {
                return(View("EditUser", model));
            }
        }
        public ActionResult AddUser()
        {
            AdminAddUpdateUserVM model = new AdminAddUpdateUserVM();

            model.AvailableRoles = IdentityPostmaster.SetAvailableRoles();

            return(View(model));
        }
        public ActionResult EditUser(string userId)
        {
            AdminAddUpdateUserVM model = new AdminAddUpdateUserVM();

            var courier = IdentityPostmaster.RetrieveUserById(userId);

            model.TargetUserId   = userId;
            model.FirstName      = courier.Package.FirstName;
            model.LastName       = courier.Package.LastName;
            model.Email          = courier.Package.Email;
            model.AvailableRoles = IdentityPostmaster.SetAvailableRoles();
            model.RoleName       = IdentityPostmaster.GetUserRole(userId).Package.Name;

            foreach (var t in model.AvailableRoles)
            {
                if (t.Text == model.RoleName &&
                    t.Value == model.RoleName)
                {
                    t.Selected = true;
                }
            }

            return(View(model));
        }