Пример #1
0
        public bool EditUser(UserViewModel userEdit)
        {
            //// Validation logic
            //if (!ValidateUser(userEdit))
            //    return false;

            //// Database logic
            //try
            //{
            //    MembershipUser editUser = new MembershipUser(
            //    Membership.UpdateUser(
            //}
            //catch
            //{
            //    return false;
            //}
            return true;
        }
Пример #2
0
 public ActionResult CreateUser(UserViewModel userToCreate)
 {
     try
     {
         if (_service.CreateUser(userToCreate))
         {
             return RedirectToAction("ListUsers");
         }
         else
         {
             return View(userToCreate);
         }
     }
     catch
     {
         return View(userToCreate);
     }
 }
Пример #3
0
        public bool CreateUser(UserViewModel userToCreate)
        {
            // Validation logic
            if (!ValidateUser(userToCreate))
                return false;

            // Database logic
            try
            {
                MembershipCreateStatus createStatus;
                MembershipUser createdUser = Membership.CreateUser(
                        userToCreate.UserName
                        , userToCreate.Password
                        , userToCreate.Email
                        , null
                        , null
                        , true
                        , out createStatus);
                if (createStatus == MembershipCreateStatus.Success)
                {
                    // Create profile
                    ProfileBase curProfile = ProfileBase.Create(createdUser.UserName);
                    curProfile.SetPropertyValue("FirstName", userToCreate.FistName);
                    curProfile.SetPropertyValue("LastName", userToCreate.LastName);
                    curProfile.SetPropertyValue("MobilePhone", userToCreate.Mobile);
                    curProfile.SetPropertyValue("HomePhone", userToCreate.HomePhone);
                    curProfile.Save();
                }
                else
                {
                    _validationDictionary.AddError("_FORM", ErrorCodeToString(createStatus));
                    return false;
                }

            }
            catch
            {
                return false;
            }
            return true;
        }
Пример #4
0
 private bool ValidateUser(UserViewModel userToValidate)
 {
     if (String.IsNullOrEmpty(userToValidate.UserName))
     {
         _validationDictionary.AddError("username", "You must specify a username.");
     }
     if (String.IsNullOrEmpty(userToValidate.Email))
     {
         _validationDictionary.AddError("email", "You must specify an email address.");
     }
     if (userToValidate.Password == null)
     {
         _validationDictionary.AddError("password", "Phải nhập password");
     }
     if (!String.Equals(userToValidate.Password, userToValidate.ConfirmPassword, StringComparison.Ordinal))
     {
         _validationDictionary.AddError("_FORM", "The new password and confirmation password do not match.");
     }
     return _validationDictionary.IsValid;
 }
Пример #5
0
 //
 // GET: /Admin/UserManage/Edit/5
 public ActionResult Edit(Guid id)
 {
     aspnet_Users cUser = _service.GetUser(id);
     UserViewModel pUser = new UserViewModel(cUser);
     return View(pUser);
 }
Пример #6
0
        public ActionResult Edit(Guid id, UserViewModel userToEdit)
        {
            try
            {
                // TODO: Add update logic here

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }