Example #1
0
        public void Search_SortByAccountStatus()
        {
            //Arrange
            var user1 = _userAccountService.FindByUserName("admin");
            var user2 = _userAccountService.Create(new UserAccountViewModel {
                UserName = "******"
            });

            _userAccountService.ChangeLock(user2, true);

            const string      id             = "";
            const string      userName       = "";
            UserAccountType?  type           = null;
            UserAccountStatus?status         = null;
            const string      registeredFrom = "";
            const string      registeredTo   = "";
            const string      sorting        = "isLocked_a";
            const int         pageNumber     = 1;
            const int         pageSize       = 10;

            //Act
            var result = _userAccountService.Search(id, userName, type, status,
                                                    registeredFrom, registeredTo, sorting, pageNumber, pageSize);

            //Assert
            Assert.That(result[0], Is.EqualTo(user1));
            Assert.That(result[1], Is.EqualTo(user2));
        }
        public ActionResult Lock(int id)
        {
            //Dont allow a user to lock his own user
            if (id == User.Identity.GetUserId <int>())
            {
                return(new HttpStatusCodeResult(HttpStatusCode.Forbidden, "You cant edit your own account"));
            }

            var account = _userAccountService.FindById(id);

            if (account == null)
            {
                return(HttpNotFound());
            }

            _userAccountService.ChangeLock(account, true);
            _userAccountService.Log(OperationType.AccountManualLock, User.Identity.GetUserId <int>(), data: "LockedUserID: " + id);

            return(RedirectToAction("View", new { id }));
        }