コード例 #1
0
        public ActionResult Edit()
        {
            ReturnUrlSet();
            if (SessionCache.UserId.HasValue)
            {
                ViewBag.AllMenu  = menuService.GetAll();
                ViewBag.UserMenu = userMenuService.GetByUser(userService.GetByEmail(SessionCache.UserEmail).Id);

                return(View("Edit", userService.GetUser(SessionCache.UserId.Value)));
            }
            else
            {
                return(RedirectToAction("InvalidParams", "Home"));
            }
        }
コード例 #2
0
        //
        // GET: /Login/Login/
        public ActionResult Login(string email, string password)
        {
            string  pass = MiscHelper.Encrypt(password);
            UserDTO user = userService.GetByEmail(email);

            if (user != null && (UserHelper.Login(user, pass) == true || user.Password == String.Empty))
            {
                List <UserMenuDTO> userMenus = userMenuService.GetByUser(user.Id).ToList();
                List <MenuDTO>     menus     = new List <MenuDTO>();

                foreach (UserMenuDTO userMenu in userMenus)
                {
                    menus.Add(menuService.GetAll().FirstOrDefault(m => m.Id == userMenu.Menu.Id));
                }

                SessionCache.CreateSession(user.Id,
                                           user.Email,
                                           menus,
                                           user.UserType);

                if (TempData["ReturnUrl"] == null || String.IsNullOrEmpty((string)TempData["ReturnUrl"]))
                {
                    return(Redirect("/Home/"));
                }
                else
                {
                    return(Redirect((string)TempData["ReturnUrl"]));
                }
            }
            else
            {
                SessionCache.LoginFailCount++;
                ViewBag.ValidationError = "Login failed.";
            }

            return(View("Index"));
        }