コード例 #1
0
        public ActionResult Index()
        {
            ViewBag.Accounts = _accountLogic.GetUserAccounts(HttpContext.Session.GetString("UserSession"));
            ViewBag.Users    = _userLogic.GetAllUsers();
            var context = _invitationLogic.GetUserInvitations((int)HttpContext.Session.GetInt32("UserId"));
            var model   = context.Select(invite => new InvitationViewModel(invite)).ToList();

            HttpContext.Session.SetInt32("MessageCount", model.Count);
            return(View("~/Views/Invitation/Invitations.cshtml", model));
        }
コード例 #2
0
ファイル: UserController.cs プロジェクト: BluRRayS/iSpendApp
        public ActionResult Login(string username, string password)
        {
            var accountLogic = new UserLogic(_userContext);

            if (accountLogic.Login(username, password))
            {
                HttpContext.Session.SetString("UserSession", username);
                HttpContext.Session.SetInt32("UserId", accountLogic.GetAccountByUsername(username).UserId);
                HttpContext.Session.SetInt32("MessageCount", _invitationLogic.GetUserInvitations(accountLogic.GetAccountByUsername(username).UserId).Count());
                return(RedirectToAction("Index", "Home"));
            }
            return(RedirectToAction("Login"));
        }