Esempio n. 1
0
        // GET: Questions
        public async Task <IActionResult> Index()
        {
            //Example of how to get the actual user that logged into the application
            User actualUser = null;

            if (!string.IsNullOrEmpty(HttpContext.Session.GetString(UsersController.ACTIVE_USERNAME)))
            {
                actualUser = model.GetUser(HttpContext.Session.GetString(UsersController.ACTIVE_USERNAME));
            }
            ViewBag.User = actualUser; //You just put at view (in C# code) ViewBag.User and get the user logged
                                       //End of the example


            var questions = await _context.Question.Where(q => q.isArchived == false)

                            .Include(q => q.Answers)
                            .Include(q => q.InterestingVotes)
                            .Include(q => q.QuestionLabels)
                            .ThenInclude(ql => ql.Label)
                            .Include(q => q.QuestionStudios)
                            .ThenInclude(qs => qs.Studio)
                            .Include(q => q.User)
                            .ToListAsync();

            questions.Sort();



            return(View(questions));
        }
        public IActionResult ManageStudios()
        {
            if (string.IsNullOrEmpty(SetActiveUser()))
            {
                return(RedirectToAction("Index", "Users", new { message = "Inicie sesión" }));
            }
            User actualUser = null;

            if (!string.IsNullOrEmpty(HttpContext.Session.GetString(UsersController.ACTIVE_USERNAME)))
            {
                actualUser = model.GetUser(HttpContext.Session.GetString(UsersController.ACTIVE_USERNAME));
            }

            if (actualUser != null)
            {
                ViewData["Admin"] = actualUser.LEVEL;
            }
            else
            {
                ViewData["Admin"] = 4;
            }
            var studios = _context.Studio.ToList();



            return(View(studios));
        }
Esempio n. 3
0
        // GET: Users/Edit/5
        public IActionResult Edit()
        {
            setActiveUser();
            string currentlyActiveUsername = HttpContext.Session.GetString(ACTIVE_USERNAME);

            if (currentlyActiveUsername == null)
            {
                return(RedirectToAction("Index", "Users", new { message = "Inicie sesión" }));
            }

            User user = model.GetUser(currentlyActiveUsername);

            if (user == null)
            {
                return(NotFound());
            }

            return(View(user));
        }
Esempio n. 4
0
        public IActionResult Index()
        {
            User actualUser = null;

            if (!string.IsNullOrEmpty(HttpContext.Session.GetString("USERNAME")))
            {
                actualUser = model.GetUser(HttpContext.Session.GetString("USERNAME"));
            }

            if (actualUser != null)
            {
                ViewData["Admin"] = actualUser.LEVEL;
            }
            else
            {
                ViewData["Admin"] = 4;
            }

            return(View());
        }