Esempio n. 1
0
        public UserView RestoreUser(int userId)
        {
            if (!ModelState.IsValid)
            {
                throw new BadRequestException("Invalid Request");
            }

            return(_userService.ActivateUser(userId));
        }
Esempio n. 2
0
        public ActionResult ValidateUser(ValidateUserViewModel model)
        {
            if (UserService.ActivateUser(model.Code))
            {
                SetMessage(UserService.ServiceTempData);
                return(RedirectToAction("Login"));
            }

            ModelState.Merge(UserService.ServiceModelState);
            return(View(model));
        }
Esempio n. 3
0
        public ActionResult DoActivate(string token)
        {
            var userActivated = UserService.ActivateUser(token);

            if (userActivated)
            {
                return(RedirectToAction("Activated", "User"));
            }
            else
            {
                return(RedirectToAction("NotWelcome", "User"));
            }
        }
Esempio n. 4
0
 public async Task <IActionResult> ActivateUser([FromBody] int id)
 {
     _logger.LogDebug("Activating user.");
     if (await _userService.ActivateUser(id))
     {
         _logger.LogDebug("User activate operation success.");
         return(Ok($"Update success"));
     }
     else
     {
         _logger.LogDebug("User activate operation failed. User not found.");
         return(BadRequest("User Update failed"));
     }
 }
Esempio n. 5
0
 public void DeactivateAndActivateUser()
 {
     using (TransactionScope ts = new TransactionScope())
     {
         UserService service = new UserService();
         User        user    = new User()
         {
             Name = "Test User", Email = "*****@*****.**"
         };
         service.CreateUser(user);
         service.DeactivateUser(user);
         Assert.IsTrue(user.Inactive);
         service.ActivateUser(user);
         Assert.IsFalse(user.Inactive);
         Assert.IsTrue(user.UserEvents.Count == 3);
     }
 }
Esempio n. 6
0
        public ActionResult Activate(string token)
        {
            var userService = new UserService();
            var user        = userService.GetUserByAccountId(new GetUserByAccountIdRequest()
            {
                AccountId = token
            }).User;

            if ((user != null) && (user.ActivationDate != null))
            {
                userService.ActivateUser(new ActivateUserRequest()
                {
                    Id = user.Id
                });
            }

            return(RedirectToAction("Index", "User"));
        }
Esempio n. 7
0
        /// <summary>
        /// Activates a newly registered account.
        /// </summary>
        /// <returns></returns>
        public ActionResult Activate(string id)
        {
            if (ApplicationSettings.UseWindowsAuthentication)
            {
                return(RedirectToAction("Index", "Home"));
            }

            if (string.IsNullOrEmpty(id))
            {
                return(RedirectToAction("Index", "Home"));
            }

            if (!UserService.ActivateUser(id))
            {
                ModelState.AddModelError("General", SiteStrings.Activate_Error);
            }

            return(View());
        }
Esempio n. 8
0
        public ActionResult ActivateDeactivate(ActivateDeactivateViewModel user)
        {
            int rowsAffected = 0;

            try
            {
                switch (user.Status)
                {
                case "Activate":
                    rowsAffected = _userService.ActivateUser(user.Username);

                    if (rowsAffected != 0)
                    {
                        ViewBag.successMessage = Constant.ActivateUserSuccessMsg;
                        return(View());
                    }
                    ViewBag.Message = Constant.ActivateUserErrorMsg;
                    return(View());

                case "Deactivate":
                    rowsAffected = _userService.DeactivateUser(user.Username);

                    if (rowsAffected != 0)
                    {
                        ViewBag.successMessage = Constant.DeactivateUserSuccessMsg;
                        return(View());
                    }
                    ViewBag.Message = Constant.DeactivationErrorMsg;
                    return(View());

                default:
                    return(View());
                }
            }
            catch (SqlException ex)
            {
                ViewBag.Message = ex.Message;
                return(View());
            }
        }
Esempio n. 9
0
 /// <summary>
 /// Activating the selected user
 /// </summary>
 /// <param name="userModel"></param>
 public void ActivateUser(UserModel userModel)
 {
     UserService.ActivateUser(userModel);
 }