Ejemplo n.º 1
0
        public ActionResult Index()
        {
            var model  = new DashboardViewModel();
            var userId = User.Identity.GetUserId();

            if (User.IsInRole("Admin") || User.IsInRole("ProjectManager"))
            {
                model.NumberProjects        = bugTrackerHelper.GetNumberProject();
                model.NumberOpenTickets     = bugTrackerHelper.GetListTicketsByStatus("Open");
                model.NumberRejectedTickets = bugTrackerHelper.GetListTicketsByStatus("Rejected");
                model.NumberResolvedTickets = bugTrackerHelper.GetListTicketsByStatus("Resolved");
                model.NumberTickets         = bugTrackerHelper.ActiveTickets().Count();

                return(View(model));
            }

            model.NumberProjects = bugTrackerHelper.GetUserProjectsById(userId).Count();

            if (User.IsInRole("Developer"))
            {
                model.NumberTicketsAssigned = bugTrackerHelper.NumberTicketsUserAssigned(userId);
                model.NumberTickets         = bugTrackerHelper.GetTicketsForDeveloper(userId).Count();
            }

            if (User.IsInRole("Submitter"))
            {
                model.NumberTicketsOwned = bugTrackerHelper.NumberTicketsUserOwned(userId);
                model.NumberTickets      = bugTrackerHelper.GetTicketsForSubmitters(userId).Count();
            }

            if (User.IsInRole("Submitter") && User.IsInRole("Developer"))
            {
                model.NumberTicketsAssigned = bugTrackerHelper.NumberTicketsUserAssigned(userId);
                model.NumberTicketsOwned    = bugTrackerHelper.NumberTicketsUserOwned(userId);
                model.NumberTickets         = bugTrackerHelper.GetTicketsForDevSubmitters(userId).Count();
            }

            return(View(model));
        }