Esempio n. 1
0
        public ActionResult MyTickets()
        {
            var user = db.Users.Find(User.Identity.GetUserId());//Get User's Identity

            //Passing Model to Partial for owner tickets
            var ticketsOwner  = db.TicketPosts.Where(x => x.OwnerUserID == user.Id).ToList();
            var DispTicketsVM = new DispTicketsVM();

            DispTicketsVM.TitleDesc         = "Tickets which " + user.DisplayName + " is the Owner/Submitter.";
            DispTicketsVM.TicketList        = ticketsOwner;
            ViewData["DispTicketsVM_Owner"] = DispTicketsVM;

            //Passing list of tickets to the partialview with ViewData
            var ticketsAssigned = db.TicketPosts.Where(x => x.AssignedToUserID == user.Id).ToList();

            ViewBag.TicketDisplayDescription = "Tickets Assigned to " + user.DisplayName;
            ViewData["TicketsCollection"]    = ticketsAssigned;
            if (User.IsInRole("Developer") || User.IsInRole("Submitter"))//Checks if user is a Developer or Submitter
            {
            }
            else
            {
                string errcode = "Access Denied, MyTickets, You are not in the Developer or Submitter Role(s). User:"******"Err403", "BT", new { errcode = errcode }));
            }
            return(View());
        }
Esempio n. 2
0
        public ActionResult GlobalTickets()
        {
            //Get All Tickets, Sorted by Created Date
            var allTicketsList    = db.TicketPosts.ToList().OrderByDescending(m => m.Created).ToList();
            var DispTicketsVM_All = new DispTicketsVM();

            DispTicketsVM_All.TitleDesc          = "All Tickets, Sorted by Created Date/Time";
            DispTicketsVM_All.TicketList         = allTicketsList;
            ViewData["DispTicketsVM_AllTickets"] = DispTicketsVM_All;


            return(View());
        }
Esempio n. 3
0
        public ActionResult MyProjects()
        {
            var user       = db.Users.Find(User.Identity.GetUserId());
            var myProjects = user.Projects.ToList().OrderBy(m => m.Name);

            if (myProjects.Count() < 1) //Checks if ther are any projects are assigned.
            {
                string errcode = "Access Denied, MyProjects, No Projects. User:"******"Err403", "BT", new { errcode = errcode }));
            }

            //Passing list of all tickets only for projects that the user is assigned.
            var AllProjectsTickets = myProjects.SelectMany(p => p.Tickets).ToList();
            var DispTicketsVM1     = new DispTicketsVM();

            DispTicketsVM1.TicketList         = AllProjectsTickets;
            DispTicketsVM1.TitleDesc          = "All Tickets from your Projects only.";
            ViewData["MyProjectsTicketsList"] = DispTicketsVM1;


            return(View(myProjects));
        }
Esempio n. 4
0
        public ActionResult PMDashboard()
        {
            //HelperMethod for Histories/Notifications
            var ticketCustomHelper = new TicketCustomHelper();
            //UserRoles Helper
            var userRolesHelper = new UserRolesHelper(db);

            var currentUser        = db.Users.Find(User.Identity.GetUserId());
            var userProjects       = currentUser.Projects.ToList();
            var AllProjectsTickets = userProjects.SelectMany(p => p.Tickets).ToList();

            //Passes All Tickets for all projects to partial view
            var DispTicketsVM1 = new DispTicketsVM();

            DispTicketsVM1.TicketList         = AllProjectsTickets;
            DispTicketsVM1.TitleDesc          = "All Tickets from your Projects only.";
            ViewData["MyProjectsTicketsList"] = DispTicketsVM1;

            //List Tickets for Each Project and allow bulk assignment
            var allDevelopers = userRolesHelper.GetAllUsersInRole("Developer").OrderBy(u => u.DisplayName);


            //Instantiate Big View Model (for encapsulating other VMs)
            var PMDashboardVM = new PMDashboardVM();

            PMDashboardVM.PMVMListForPartials = new List <PMTicketProjectsSelectVM>();
            PMDashboardVM.MyProjects          = userProjects;

            var projectsArr = userProjects.ToArray();

            for (var i = 0; i < projectsArr.Length; i++)
            {
                //Instantiate New VM for each Project's Developers(select list) & UnAssigned Tickets(table/checkboxes)
                var PMTicketProjectsSelectVM = new PMTicketProjectsSelectVM();
                PMTicketProjectsSelectVM.PMUsersInProjectVMList  = new List <PMUsersInProjectVM>();
                PMTicketProjectsSelectVM.PMAssignUsersTicketList = new List <PMAssignUsersTicketVM>();
                //Get Developers & Unassigned Tickets
                var developersInProject = allDevelopers.Where(u => u.Projects.Contains(projectsArr[i])).ToArray();
                var ticketsInProject    = projectsArr[i].Tickets.Where(x => x.AssignedToUser == null).ToArray();

                //Build Developer User List
                for (var x = 0; x < developersInProject.Length; x++)
                {
                    PMTicketProjectsSelectVM.PMUsersInProjectVMList.Add(new PMUsersInProjectVM()
                    {
                        ProjectId = projectsArr[i].Id, UserDisplayName = developersInProject[x].DisplayName, UserId = developersInProject[x].Id
                    });
                }
                //Build Unassigned Ticket List w/ checkbox values
                for (var x = 0; x < ticketsInProject.Length; x++)
                {
                    PMTicketProjectsSelectVM.PMAssignUsersTicketList.Add(new PMAssignUsersTicketVM()
                    {
                        ProjectId = projectsArr[i].Id, TicketId = ticketsInProject[x].Id, Ticket = ticketsInProject[x], IsChecked = false
                    });
                }
                //Adds Developers & Tickets as one List Item
                PMTicketProjectsSelectVM.ProjectId   = projectsArr[i].Id;
                PMTicketProjectsSelectVM.ProjectName = projectsArr[i].Name;
                PMDashboardVM.PMVMListForPartials.Add(PMTicketProjectsSelectVM);
            }
            var ticketHistoriesList = new List <TicketHistory>();

            foreach (var item in userProjects)
            {
                var newList = db.TicketHistories.OrderByDescending(h => h.UpdatedTime).Where(h => h.Ticket.ProjectID == item.Id).ToList();
                ticketHistoriesList.AddRange(newList);
            }
            var projectHistoriesList = ticketHistoriesList.OrderByDescending(h => h.UpdatedTime).ToList();

            //Data for TicketHistories
            var historyTimesList  = projectHistoriesList.Select(x => x.UpdatedTime).Distinct().ToList();
            var ticketHistoryList = new List <TicketHistory>().ToArray();


            var TopList = new List <TopDispHist>();

            foreach (var item in historyTimesList)
            {
                var TopDispHist = new TopDispHist();
                TopDispHist.HistEntriesList = new List <TicketHistory>();

                var ticketEntry = projectHistoriesList.Where(t => t.UpdatedTime == item);
                TopDispHist.HistEntriesList.AddRange(ticketEntry.ToList());
                TopDispHist.Created     = item;
                TopDispHist.DisplayName = TopDispHist.HistEntriesList.First().UpdatedByUser.DisplayName;
                TopList.Add(TopDispHist);
            }

            ViewData["ticketHistoryList"] = (List <TopDispHist>)TopList.Take(15).ToList();

            var VMList = PMDashboardVM.PMVMListForPartials;

            ViewData["ViewModelList"] = (List <PMTicketProjectsSelectVM>)VMList;



            return(View(PMDashboardVM));
        }