Esempio n. 1
0
        public IActionResult Profile(string profileName)
        {
            ModelsCombined.User user = DB.Users.Where(u => u.userName == profileName).FirstOrDefault();

            IEnumerable <Post> userPosts = DB.Posts.Where(u => u.posterName == profileName);

            ViewData["User"]  = DB.Users.Where(u => u.userName == profileName).FirstOrDefault();
            ViewData["Posts"] = DB.Posts.Where(u => u.posterName == profileName);

            return(View(userPosts));
        }
Esempio n. 2
0
        public IActionResult Login(ModelsCombined.User compare)
        {
            ModelsCombined.User user = DB.Users.Where(u => u.userName == compare.userName && u.password == compare.password).FirstOrDefault();

            if (user != null)
            {
                HttpContext.Session.SetString("username", user.userName.ToString());
                return(RedirectToAction("Index"));
            }
            else
            {
                return(RedirectToAction("Login"));
            }
        }