public ActionResult Edit(int id)
        {
            var model = new UserViewModel();

            if (id != -1)
            {
                var svc = new UserAppService();
                var o = svc.GetUser(id);
                model.UserId = o.UserId;
                model.UserName = o.UserName;
                model.LastLoginDateText = CommonHelper.GetPrettyDate(o.LastLoginDate); 
                model.HasChangePassword = o.HasChangePassword;
                model.UserStateId = o.UserStateId;
                model.UserStates = GetUserStates();
                model.UserRoles = o.UserRoles.ToList();


            }
            else
            {
                model.UserId = -1;
                model.UserName = string.Empty;
                model.LastLoginDateText = CommonHelper.GetPrettyDate(null);
                model.HasChangePassword = true;
                model.UserStates = GetUserStates();
            }



            return View(model);
        }
        public void GetUserByIdTestDadosInvalidos()
        {
            var userAppService = new UserAppService();
            var result         = userAppService.GetUser(-1);

            Assert.IsFalse(result.IsSuccess);
            Assert.IsInstanceOfType(result, typeof(ResultModel));
        }
        public void GetUserByIdTestDadosValidos()
        {
            var userAppService = new UserAppService();
            var result         = (ResultModelSingle <User>)userAppService.GetUser(1);

            Assert.IsTrue(result.IsSuccess);
            Assert.IsNotNull(result.ResultObject);
            Assert.AreEqual(result.ResultObject.Id, 1);
        }
        public void GetUserTestManyDadosValidos()
        {
            var userAppService = new UserAppService();
            var filterObj      = new User();
            var result         = (ResultModelMany <User>)userAppService.GetUser(filterObj);

            Assert.IsTrue(result.IsSuccess);
            Assert.IsTrue(result.ResultObject.Count > 0);
        }
        public void GetUserTestManyDadosInvalidos()
        {
            var userAppService = new UserAppService();
            var filterObj      = new User {
                SuperiorId = 999
            };
            var result = (ResultModelMany <User>)userAppService.GetUser(filterObj);

            Assert.IsTrue(result.IsSuccess);
            Assert.AreEqual(result.ResultObject.Count, 0);
        }
 public static void UpdateLastLoginDate(int userId) {
     var svc = new UserAppService();
     var usr = svc.GetUser(userId);
     usr.LastLoginDate = DateTime.Now;
     svc.SaveUser(usr);
 }