示例#1
0
        public IActionResult Profile(string username, string password, string method)
        {
            setActiveUser();
            User found = model.FindUser(username, password, method);

            if (found == null)
            {
                return(RedirectToAction("Index", "Users", new { message = "Error, prueba de nuevo" }));
            }
            else
            {
                //Only username it's saved for have a better security but this might be slower because have to search user every time it's needed
                HttpContext.Session.SetString(ACTIVE_USERNAME, found.USERNAME);
                ViewData["ACTIVE_USER"] = username;
                return(View(found));
            }
        }
        public IActionResult Profile(string username, string password, string method)
        {
            User found = model.FindUser(username, password, method);

            found.QUESTIONS_ASKED    = _context.Question.Count(a => a.UserId == found.ID); //We profile added this because it wasn't implemented action of increase or decrease when a user makes or answer a question
            found.QUESTIONS_ANSWERED = _context.Answer.Count(a => a.UserId == found.ID);
            if (found == null)
            {
                return(RedirectToAction("Index", "Users", new { message = "Error, prueba de nuevo" }));
            }
            else
            {
                //Only username it's saved for have a better security but this might be slower because have to search user every time it's needed
                HttpContext.Session.SetString(ACTIVE_USERNAME, found.USERNAME);
                ViewData["ACTIVE_USER"] = username;
                SetActiveUser();
                return(View(found));
            }
        }