Esempio n. 1
0
        public ActionResult RegisterUserEdit(User user, int id)
        {
            var model = AuthenticationDB.GetUserByEmail(user.Email);

            if (model != null)
            {
                if (model.UserId != user.UserId)
                {
                    ModelState.AddModelError("Warning Email", "Sorry: Email already Exists");
                    return(View(user));
                }
            }
            else
            {
                model = AuthenticationDB.GetUserById(user.UserId);
            }
            model.FullName             = user.FullName;
            model.Email                = user.Email;
            model.IsActive             = user.IsActive;
            model.Phone                = user.Phone;
            model.CommunicationAddress = user.CommunicationAddress;
            AuthenticationDB.Save(model);

            return(RedirectToAction("RegisterUser"));
        }
Esempio n. 2
0
        public ActionResult ChangeStatus(int id)
        {
            var model = AuthenticationDB.GetUserById(id);

            model.IsActive = !model.IsActive;
            AuthenticationDB.Save(model);
            return(RedirectToAction("RegisterUser"));
        }
Esempio n. 3
0
        public ActionResult Registration(RegistrationView registrationView)
        {
            bool   statusRegistration  = false;
            string messageRegistration = string.Empty;

            if (ModelState.IsValid)
            {
                // Email Verification
                string userName = Membership.GetUserNameByEmail(registrationView.Email);
                if (!string.IsNullOrEmpty(userName))
                {
                    ModelState.AddModelError("Warning Email", "Sorry: Email already Exists");
                    return(View(registrationView));
                }

                var user = new User()
                {
                    FullName             = registrationView.FullName,
                    Phone                = registrationView.Phone,
                    CommunicationAddress = registrationView.CommunicationAddress,
                    Email                = registrationView.Email,
                    Password             = registrationView.Password,
                    IsActive             = true,
                    RolesId              = ((int)RoleEnum.Agent).ToString()
                };
                AuthenticationDB.Save(user);


                messageRegistration = "Your account has been created successfully.";
                statusRegistration  = true;
            }
            else
            {
                messageRegistration = "Something Wrong!";
            }
            ViewBag.Message = messageRegistration;
            ViewBag.Status  = statusRegistration;

            return(View(registrationView));
        }