Ejemplo n.º 1
0
        public PartialViewResult Layout()
        {
            Models.ApplicationUser user = DefaultUserManager.FindByEmailAsync(User.Identity.Name).Result;

            HomeTicketAndProjectsViewModel model = new HomeTicketAndProjectsViewModel();

            if (User.IsInRole(Submitter))
            {
                model.Tickets  = user.CreatedTickets.Where(p => !p.Project.Archived).Select(p => p).ToList();
                model.Projects = user.Projects.Where(p => !p.Archived).Select(p => p).ToList();
            }
            else if (User.IsInRole(Developer))
            {
                model.Tickets  = user.AssignedTickets.Where(p => !p.Project.Archived).Select(p => p).ToList();
                model.Projects = user.Projects.Where(p => !p.Archived).Select(p => p).ToList();
            }
            else
            {
                model.Tickets  = DbContext.Tickets.Where(q => !q.Project.Archived).Select(p => p).ToList();
                model.Projects = DbContext.Projects.Where(p => !p.Archived).Select(p => p).ToList();
            }

            return(PartialView("_LayoutTicketsAndProjects", model));
        }