Пример #1
0
        public ActionResult UserEdit(int UserID)
        {
            var user = _repo.GetUserByID(UserID);


            UserViewModel uvm = new UserViewModel()
            {
                UserID        = user.UserID,
                UserName      = user.UserName.Trim(),
                Active        = !(user.Inactive ?? false),
                LastName      = user.LastName.Trim(),
                FirstName     = user.FirstName.Trim(),
                Password      = user.Password.Trim(),
                EMail         = String.IsNullOrEmpty(user.EMail) ? "" : user.EMail.Trim(),
                assignedRoles = user.Roles.ToList()
            };

            uvm.selectRoles = new SelectList(_repo.GetRoles(), "RoleID", "RoleName");

            bool IsSaved;

            if (TempData["IsSaved"] != null)
            {
                IsSaved         = (bool)TempData["IsSaved"];
                ViewBag.IsSaved = IsSaved;
            }
            else
            {
                ViewBag.IsSaved = false;
            }


            return(View("UserEdit", uvm));
        }