Example #1
0
        // GET: /Login/
        public RedirectResult Login(ViewModelRegistrationLogin login)
        {
            User user    = null;
            User newUser = null;

            try
            {
                user = new User()
                {
                    Email    = login.ViewModelLogin.EmailForLogin,
                    Password = login.ViewModelLogin.PasswordForLogin
                };

                newUser         = userManager.GetUserByEmail(user);
                newUser.Profile = profileManager.GetProfileById(newUser.Profile.Id);
            }
            catch (Exception e)
            {
                user = new User()
                {
                    Email    = login.ViewModelLogin.EmailForLogin,
                    Password = login.ViewModelLogin.PasswordForLogin
                };
                newUser = userManager.GetUserByEmail(user);
            }

            if (loginManager.login(user))
            {
                Session["User"] = newUser;
                return(Redirect("/NewsFeed/Index"));
            }
            else
            {
                return(Redirect("/Register/Registation"));
            }
        }
Example #2
0
        public bool Layout()
        {
            var user = Session["User"] as User;

            if (user == null || Session["User"] == null)
            {
                return(false);
            }

            if (loginManager.login(user))
            {
                FriendReqeust();
                ViewBag.FriendRequest      = Session["FriendRequest"];
                ViewBag.CurrentUserProfile = user.Profile;
                ViewBag.Name = user.Profile.FristName + " " + user.Profile.LastName;
                return(true);
            }
            return(false);
        }