コード例 #1
0
ファイル: UserManagerService.cs プロジェクト: etuannv/TNVTH
        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
ファイル: UserManageController.cs プロジェクト: etuannv/TNVTH
 public ActionResult CreateUser(UserViewModel userToCreate)
 {
     try
     {
         if (_service.CreateUser(userToCreate))
         {
             return RedirectToAction("ListUsers");
         }
         else
         {
             return View(userToCreate);
         }
     }
     catch
     {
         return View(userToCreate);
     }
 }
コード例 #3
0
ファイル: UserManagerService.cs プロジェクト: etuannv/TNVTH
        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
ファイル: UserManagerService.cs プロジェクト: etuannv/TNVTH
 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
ファイル: UserManageController.cs プロジェクト: etuannv/TNVTH
 //
 // 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
ファイル: UserManageController.cs プロジェクト: etuannv/TNVTH
        public ActionResult Edit(Guid id, UserViewModel userToEdit)
        {
            try
            {
                // TODO: Add update logic here

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