public ActionResult Create(int?projectId) { ViewBag.DeveloperId = new SelectList(db.Users, "Id", "FirstName"); //I need to somehow produce a list of only my Projects and then put that list into the SelectList var myUserId = User.Identity.GetUserId(); var myProjects = projHelper.ListUserProjects(myUserId); if (projectId == null) { ViewBag.ProjectId = new SelectList(myProjects, "Id", "Name"); } ViewBag.SubmitterId = new SelectList(db.Users, "Id", "FirstName"); ViewBag.TicketPriorityId = new SelectList(db.TicketPriorities, "Id", "Name"); ViewBag.TicketStatusId = new SelectList(db.TicketStatuses, "Id", "Name"); ViewBag.TicketTypeId = new SelectList(db.TicketTypes, "Id", "Name"); var newTicket = new Ticket(); if (projectId != null) { newTicket.ProjectId = (int)projectId; } return(View(newTicket)); }
public ActionResult MyIndex() { var myTickets = new List <Ticket>(); var userId = User.Identity.GetUserId(); var myRole = roleHelper.ListUserRoles(User.Identity.GetUserId()); switch (myRole.FirstOrDefault()) { case "Project Manager": var myProjects = projHelper.ListUserProjects(userId); foreach (var project in myProjects) { myTickets.AddRange(db.Tickets.Where(t => t.ProjectId == project.Id)); } break; case "Developer": myTickets = db.Tickets.Where(t => t.AssignedToUserId == userId).ToList(); break; case "Submitter": myTickets = db.Tickets.Where(t => t.OwnerUserId == userId).ToList(); break; default: break; } return(View(myTickets)); }
// GET: Admin public ActionResult UserIndex() { var projects = db.Projects.ToList(); var roles = db.Roles.ToList(); var users = db.Users.Select(u => new UserIndexViewModel { Id = u.Id, FullName = u.LastName + ", " + u.FirstName, DisplayName = u.DisplayName, AvatarURL = u.AvatarURL, Email = u.Email, ActiveRole = u.ActiveRole }).ToList(); foreach (var user in users) { user.CurrentRole = new SelectList(roles, "Name", "Name", roleHelper.ListUserRoles(user.Id).FirstOrDefault()); user.CurrentProjects = new MultiSelectList(projects, "Id", "Name", projectHelper.ListUserProjects(user.Id).Select(u => u.Id)); } foreach (var user in users) { user.ActiveRole = roleHelper.GetUserRole(user.Id) ; } return(View(users)); }
public ActionResult EditProfile(string userId) { var projects = db.Projects.ToList(); var roles = db.Roles.ToList(); //var userId = User.Identity.GetUserId(); if (linkHelper.UserNoRoleView()) { var noroleid = userId; return(RedirectToAction("EditProfileNorole", "Members", new { userId = noroleid })); } var member = db.Users.Select(user => new UserProfileViewModel { Id = user.Id, FirstName = user.FirstName, LastName = user.LastName, DisplayName = user.DisplayName, Email = user.Email, PhoneNumber = user.PhoneNumber, AvatarURL = user.AvatarURL }).FirstOrDefault(u => u.Id == userId); member.CurrentRole = new SelectList(roles, "Name", "Name", roleHelper.ListUserRoles(member.Id).FirstOrDefault()); member.CurrentProjects = new MultiSelectList(projects, "Id", "Name", projectHelper.ListUserProjects(member.Id).Select(u => u.Id)); return(View(member)); }
// GET: Chart public JsonResult TicketStatusChartData() { var dataSet = new List <MorrisBarChartData>(); var ticketStatuses = db.TicketStatus.ToList(); var userId = User.Identity.GetUserId(); var Projts = projectHelper.ListUserProjects(userId); var Ticts = new List <Ticket>(); if (User.IsInRole("Admin")) { foreach (var ticketStatus in ticketStatuses) { var value = db.TicketStatus.Find(ticketStatus.Id).Tickets.Count(); dataSet.Add(new MorrisBarChartData { label = ticketStatus.StatusName, value = value }); } } else if (User.IsInRole("Project Manager")) { foreach (var project in Projts) { foreach (var ticket in project.Tickets) { Ticts.Add(ticket); } } foreach (var ticketStatus in ticketStatuses) { dataSet.Add(new MorrisBarChartData { label = ticketStatus.StatusName, value = Ticts.Where(t => t.TicketStatus.StatusName == ticketStatus.StatusName).Count() }); } } else if (User.IsInRole("Developer")) { foreach (var ticketStatus in ticketStatuses) { var value = db.TicketStatus.Find(ticketStatus.Id).Tickets.Where(t => t.AssignedToUserId == userId).Count(); dataSet.Add(new MorrisBarChartData { label = ticketStatus.StatusName, value = value }); } } else if (User.IsInRole("Submitter")) { foreach (var ticketStatus in ticketStatuses) { var value = db.TicketStatus.Find(ticketStatus.Id).Tickets.Where(t => t.OwnerUserId == userId).Count(); dataSet.Add(new MorrisBarChartData { label = ticketStatus.StatusName, value = value }); } } return(Json(dataSet)); }
public ActionResult MyProjTickets() { var userId = User.Identity.GetUserId(); var myProjects = projHelper.ListUserProjects(userId).ToList(); return(View(myProjects)); }
public ActionResult Create(int?projectId) { ViewBag.DeveloperId = new SelectList(db.Users, "Id", "FirstName"); var myUserId = User.Identity.GetUserId(); var myProjects = projHelper.ListUserProjects(myUserId); if (projectId != null) { ViewBag.ProjectId = new SelectList(myProjects, "Id", "Name"); } ViewBag.SubmitterId = new SelectList(db.Users, "Id", "FirstName"); ViewBag.TicketPriorityId = new SelectList(db.TicketPriorities, "Id", "Name"); ViewBag.TicketStatusId = new SelectList(db.TicketStatus, "Id", "Name"); ViewBag.TicketTypeId = new SelectList(db.TicketTypes, "Id", "Name"); var newTicket = new Ticket(); if (projectId != null) { newTicket.ProjectId = (int)projectId; } return(View(newTicket)); }
public ActionResult ManageProjectAssignments() { var emptyCustomUserDataList = new List <CustomUserData>(); var users = db.Users.ToList(); //I have decided that it should work in this way //Load up Multi Select List of Users ViewBag.UserIds = new MultiSelectList(users, "Id", "FullName"); //Load up a Multi Select List of Projects ViewBag.ProjectIds = new MultiSelectList(db.Projects, "Id", "Name"); //Load up the View Model foreach (var user in users) { emptyCustomUserDataList.Add(new CustomUserData { FirstName = user.FirstName, LastName = user.LastName, Email = user.Email, ProjectNames = projHelper.ListUserProjects(user.Id).Select(p => p.Name).ToList() }); } return(View(emptyCustomUserDataList)); }
public ActionResult ManageProjectAssignments() { var emptyCustomUserData = new List <CustomUserData>(); var users = db.Users.ToList(); //load a multi select of users ViewBag.UserIds = new MultiSelectList(db.Users, "Id", "FullName"); //load a multi select of projects ViewBag.ProjectIds = new MultiSelectList(db.Projects, "Id", "Name"); foreach (var user in users) { emptyCustomUserData.Add(new CustomUserData { ProjectNames = projHelper.ListUserProjects(user.Id).Select(p => p.Name).ToList(), RoleName = rolesHelper.ListUserRoles(user.Id).FirstOrDefault(), DisplayName = user.DisplayName, FirstName = user.FirstName, LastName = user.LastName, Email = user.Email }); } //load the viewmodel return(View(emptyCustomUserData)); }
public ActionResult ManageUserProjects(string userId) { var myProjects = projectHelper.ListUserProjects(userId).Select(p => p.Id); ViewBag.Projects = new MultiSelectList(db.Projects.ToList(), "Id", "Name", myProjects); return(View()); }
public ActionResult ManageProjects() { var userId = User.Identity.GetUserId(); var userRole = userRolesHelper.ListUserRoles(userId).FirstOrDefault(); var users = db.Users.Select(u => new UserProfileViewModel { Id = u.Id, FirstName = u.FirstName, LastName = u.LastName, DisplayName = u.DisplayName, AvatarUrl = u.AvatarUrl, Email = u.Email }).ToList(); ViewBag.Users = new MultiSelectList(db.Users.ToList(), "Id", "FullNameWithEmail"); if (userRole == "ProjectManager") { var projList = projHelper.ListUserProjects(userId); ViewBag.ProjectName = new MultiSelectList(projList); } else { ViewBag.ProjectName = new MultiSelectList(db.Projects.ToList(), "Id", "Name"); } return(View(users)); }
public ActionResult Edit(string id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ApplicationUser applicationUser = db.Users.Find(id); if (applicationUser == null) { return(HttpNotFound()); } var currentRole = roleHelp.ListUserRoles(id).FirstOrDefault(); ViewBag.Roles = new SelectList(db.Roles, "Name", "Name", currentRole); var projIDs = new List <int>(); var projs = proj.ListUserProjects(id); foreach (var project in projs) { projIDs.Add(project.ID); } ViewBag.Projects = new MultiSelectList(db.Projects, "Id", "Name", projIDs); return(View(applicationUser)); }
// GET: Users/Edit/5 public ActionResult Edit(string id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ApplicationUser applicationUser = db.Users.Find(id); if (applicationUser == null) { return(HttpNotFound()); } //set up a selectlist so I can select the role I want my user to occupy var occupiedRole = rolesHelper.ListUserRoles(id).FirstOrDefault(); ViewBag.Roles = new SelectList(db.Roles, "Name", "Name", occupiedRole); var myProjectIds = new List <int>(); var myProjects = projHelper.ListUserProjects(id); foreach (var project in myProjects) { myProjectIds.Add(project.Id); } ViewBag.Projects = new MultiSelectList(db.Projects, "Id", "Name", myProjectIds); return(View(applicationUser)); }
public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Ticket ticket = db.Tickets.Find(id); if (ticket == null) { return(HttpNotFound()); } var myProjects = projectHelper.ListUserProjects(User.Identity.GetUserId()); ProjectsHelper projectsHelper = new ProjectsHelper(); List <ApplicationUser> projectusers = new List <ApplicationUser>(); List <string> projectDevIds = new List <string>(); foreach (Project project in myProjects) { projectDevIds = projectsHelper.UsersInRoleOnProject(project.Id, "Developer"); } foreach (string devId in projectDevIds) { ApplicationUser devUser = db.Users.Find(devId); projectusers.Add(devUser); } ViewBag.AssignedToUserId = new SelectList(projectusers, "Id", "DisplayName", ticket.AssignedToUserId); return(View(ticket)); }
public ActionResult ProjectAssign(string id) { ViewBag.UserId = id; var occupiedProjects = projHelper.ListUserProjects(id).Select(p => p.Id); ViewBag.AllProjects = new MultiSelectList(db.Projects, "Id", "Name", occupiedProjects); return(View()); }
public ActionResult Index(DashboardViewModel dashview) { var allUsers = db.Users.ToList(); var user = db.Users.Find(User.Identity.GetUserId()); if (roleHelper.ListUserRoles(user.Id).FirstOrDefault() == "Admin") { dashview.ApplicationUsers = allUsers; dashview.UserCount = allUsers.Count(); dashview.AllProjects = db.Projects.ToList(); dashview.AllTickets = db.Tickets.ToList(); } else if (roleHelper.ListUserRoles(user.Id).FirstOrDefault() == "Project Manager") { dashview.ApplicationUsers = allUsers; dashview.AllProjects = projHelper.ListUserProjects(user.Id); dashview.AllTickets = projHelper.ListUserProjects(user.Id).SelectMany(p => p.Tickets).ToList(); } else if (roleHelper.ListUserRoles(user.Id).FirstOrDefault() == "Developer") { dashview.AllProjects = projHelper.ListUserProjects(user.Id); dashview.AllTickets = ticketHelper.ListMyTickets(); } else if (roleHelper.ListUserRoles(user.Id).FirstOrDefault() == "Submitter") { dashview.AllProjects = projHelper.ListUserProjects(user.Id); dashview.AllTickets = ticketHelper.ListMyTickets(); } //var dashboardVm = new DashboardViewModel() //{ // UserCount = allUsers.Count(), // ApplicationUsers = db.Users.ToList(), // HighPriorityTicketCount = allTickets.Where(t => t.TicketPriority.Name == "High").Count(), // NewTicketCount = allTickets.Where(t => t.TicketStatus.Name == "New").Count(), // TotalComments = db.TicketComments.Count(), // AllProjects = Projects.ToList(), // AllTickets = db.Tickets.ToList() //}; //dashboardVm.ProjectVM.ProjectCount = 5; //dashboardVm.ProjectVM.AllProjects = db.Projects.ToList(); //dashboardVm.ProjectVM.AllPMs = roleHelper.UsersInRoles("Project Manager").ToList(); return(View(dashview)); }
// GET: Admin public ActionResult ProjectAssign(string id) { //Get a listing of project I am already assigned to var myProjectIds = projectHelper.ListUserProjects(id).Select(p => p.Id); ViewBag.UserId = id; ViewBag.AllProjects = new MultiSelectList(db.Projects, "Id", "Name", myProjectIds); return(View()); }
public ActionResult UserIndex() { var user = db.Users.Find(User.Identity.GetUserId()); var userProjects = projectsHelper.ListUserProjects(user.Id); ViewBag.UserIndexFlag = true; ViewBag.UserId = user.Id; return(View("Index", userProjects)); }
public ActionResult ManageUserProjects(string userId) { ViewBag.UserObject = db.Users.Find(userId); //I just need a list of projects that this user is on. . . var myProjects = projectHelper.ListUserProjects(userId).Select(p => p.Id); ViewBag.Projects = new MultiSelectList(db.Projects.ToList(), "Id", "Name", myProjects); return(View()); }
public ActionResult ManageUserProjects(string userId) { var projects = db.Projects.ToList(); var currentProjects = projHelper.ListUserProjects(userId); ViewBag.UserId = userId; ViewBag.ProjectNames = new MultiSelectList(db.Projects.ToList(), "Id", "Name", currentProjects); return(View(currentProjects)); }
public ActionResult Index() { var dashboardData = new DashboardVM(); var userId = User.Identity.GetUserId(); var myRole = "Guest"; if (userId != null) { myRole = roleHelper.ListUserRoles(User.Identity.GetUserId()).FirstOrDefault(); } switch (myRole) { case "Admin": dashboardData.RecentProjects = db.Projects.Take(5).ToList(); dashboardData.RecentTickets = db.Tickets.OrderByDescending(tn => tn.Created).Take(5).ToList(); dashboardData.AllUsers = db.Users.ToList(); dashboardData.RecentAttachments = db.TicketAttachments.OrderByDescending(tn => tn.Created).Take(5).ToList(); dashboardData.RecentComments = db.TicketComments.OrderByDescending(c => c.Created).Take(5).ToList(); dashboardData.RecentHistories = db.TicketHistories.OrderByDescending(h => h.ChangedDate).Take(5).ToList(); break; case "Project Manager": dashboardData.RecentProjects = projectHelper.ListUserProjects(userId).Take(5).ToList(); dashboardData.RecentTickets = ticketHelper.GetMyProjectTickets(userId).Take(5).ToList(); dashboardData.AllUsers = db.Users.ToList(); dashboardData.RecentAttachments = db.TicketAttachments.Where(t => t.UserId == userId).OrderByDescending(tn => tn.Created).Take(5).ToList(); dashboardData.RecentComments = db.TicketComments.Where(c => c.UserId == userId).OrderByDescending(com => com.Created).Take(5).ToList(); dashboardData.RecentHistories = db.TicketHistories.Where(h => h.UserId == userId).OrderByDescending(his => his.ChangedDate).Take(5).ToList(); break; case "Developer": dashboardData.RecentProjects = projectHelper.ListUserProjects(userId).Take(5).ToList(); dashboardData.RecentTickets = db.Tickets.Where(t => t.AssignedToUserId == userId).Take(5).ToList(); dashboardData.AllUsers = db.Users.ToList(); dashboardData.RecentAttachments = db.TicketAttachments.Where(a => a.Ticket.AssignedToUserId == userId).OrderByDescending(att => att.Created).Take(5).ToList(); dashboardData.RecentComments = db.TicketComments.Where(c => c.Ticket.AssignedToUserId == userId).OrderByDescending(com => com.Created).Take(5).ToList(); dashboardData.RecentHistories = db.TicketHistories.Where(h => h.Ticket.AssignedToUserId == userId).OrderByDescending(his => his.ChangedDate).Take(5).ToList(); break; case "Submitter": dashboardData.RecentProjects = projectHelper.ListUserProjects(userId).Take(5).ToList(); dashboardData.RecentTickets = db.Tickets.Where(t => t.OwnerUserId == userId).Take(5).ToList(); dashboardData.AllUsers = db.Users.ToList(); dashboardData.RecentAttachments = db.TicketAttachments.Where(a => a.Ticket.OwnerUserId == userId).OrderByDescending(att => att.Created).Take(5).ToList(); dashboardData.RecentComments = db.TicketComments.Where(c => c.Ticket.OwnerUserId == userId).OrderByDescending(com => com.Created).Take(5).ToList(); dashboardData.RecentHistories = db.TicketHistories.Where(h => h.Ticket.OwnerUserId == userId).OrderByDescending(his => his.ChangedDate).Take(5).ToList(); break; default: ViewBag.Message = "You will not be able to see any data until you are assigned to a role."; break; } return(View(dashboardData)); }
public ActionResult Create() { var userId = User.Identity.GetUserId(); var myProjects = projectsHelper.ListUserProjects(userId); ViewBag.ProjectId = new SelectList(myProjects, "Id", "Name"); ViewBag.TicketPriorityId = new SelectList(db.TicketPriorities, "Id", "Name"); ViewBag.TicketTypeId = new SelectList(db.TicketTypes, "Id", "Name"); return(View()); }
public ActionResult Create() { var userId = User.Identity.GetUserId(); ViewBag.AssignedToUserId = new SelectList(db.Users, "Id", "FirstName"); ViewBag.OwnerUserId = new SelectList(db.Users, "Id", "FirstName"); ViewBag.ProjectId = new SelectList(projectsHelper.ListUserProjects(userId), "Id", "Name"); ViewBag.TicketPriorityId = new SelectList(db.TicketPriorities, "Id", "Name"); ViewBag.TicketStatusId = new SelectList(db.TicketStatuses, "Id", "Name"); ViewBag.TicketTypeId = new SelectList(db.TicketTypes, "Id", "Name"); return(View()); }
public ActionResult ManageProjects(string userId) { var currentProject = projectHelper.ListUserProjects(userId).FirstOrDefault(); ViewBag.UserId = userId; ViewBag.UserProject = new SelectList(db.Projects.ToList(), "Id", "Name", currentProject.Id); return(View()); }
public ActionResult Create() { var myProjects = projHelper.ListUserProjects(User.Identity.GetUserId()); if (myProjects.Count > 0) { ViewBag.ProjectId = new SelectList(myProjects, "Id", "Name"); ViewBag.TicketTypeId = new SelectList(db.TicketTypes, "Id", "Name"); ViewBag.TicketPriorityId = new SelectList(db.TicketPriorities, "Id", "Name"); return(View(new Ticket())); } return(RedirectToAction("Error", new { message = TicketError.NoProjects })); }
public ActionResult PMProjectTickets() { var tickets = new List <Ticket>(); //empty list of tickets var projects = projectHelper.ListUserProjects(User.Identity.GetUserId()); //get projects this user is on foreach (var project in projects) //loop through each project in the projects user is on { foreach (var ticket in project.Tickets) //loop through the tickets of each individual project user is on { tickets.Add(ticket); //add those tickets to the empty ticket list } } return(View("Index", tickets)); }
public ActionResult UsersIndex() { var usersInfo = new List <IndexUsersViewModel>(); var allUsers = db.Users.ToList(); foreach (var user in allUsers) { var userInfo = new IndexUsersViewModel(); userInfo.User = user; userInfo.Projects = projectHelper.ListUserProjects(user.Id); userInfo.role = roleHelper.ListUserRoles(user.Id); usersInfo.Add(userInfo); } return(View(usersInfo.ToList())); }
public ActionResult Create() { var user = db.Users.Find(User.Identity.GetUserId()); var userTickets = ticketHelper.MyProjectTickets(user.Id).Where(t => t.Archived == false).ToList(); var userProjects = projectHelper.ListUserProjects(user.Id).Where(t => t.Archived == false).ToList(); var adminUsers = userRolesHelper.UsersInRole("Admin"); var usersOnProjects = new List <ApplicationUser>(); var tempUsers = new List <ApplicationUser>(); if (User.IsInRole("Admin")) { ViewBag.TicketId = new SelectList(db.Tickets, "Id", "Title"); ViewBag.UserId = new SelectList(db.Users, "Id", "DisplayName"); } else { foreach (var project in userProjects) { foreach (var currentUser in project.ProjectUsers) { tempUsers.Add(currentUser); } } foreach (var admin in adminUsers) { tempUsers.Add(admin); } usersOnProjects = tempUsers.Distinct().ToList(); //ViewBag.TicketId = new SelectList(db.Tickets, "Id", "Title"); ViewBag.TicketId = new SelectList(userTickets, "Id", "Title"); //ViewBag.UserId = new SelectList(db.Users, "Id", "DisplayName"); ViewBag.UserId = new SelectList(usersOnProjects, "Id", "DisplayName"); } return(View()); }
public ActionResult ManageProjectUsers() { var AdminId = db.Users.ToList().Where(u => u.Id == User.Identity.GetUserId()); ViewBag.AdminId = new SelectList(AdminId, "Id", "FullName"); //ViewBag.AdminId = new SelectList(roleHelper.UsersIn2Roles("Admin", "DemoAdmin"), "Id", "FullName"); ViewBag.Projects = new MultiSelectList(db.Projects, "Id", "Name"); ViewBag.ProjectManagerId = new SelectList(roleHelper.UsersIn2Roles("Project_Manager", "DemoProject_Manager"), "Id", "FullName"); ViewBag.Developers = new MultiSelectList(roleHelper.UsersIn2Roles("Developer", "DemoDeveloper"), "Id", "FullName"); ViewBag.Submitters = new MultiSelectList(roleHelper.UsersIn2Roles("Submitter", "DemoSubmitter"), "Id", "FullName"); var myData = new List <UserProjectListViewModel>(); UserProjectListViewModel userVM = null; foreach (var user in db.Users.ToList()) { userVM = new UserProjectListViewModel { Name = $"{user.FullName}", ProjectNames = projHelper.ListUserProjects(user.Id).Select(p => p.Name).ToList() //ProjectNames = projHelper.ListUserProjects(user.Id).Count() == 0 ? "N/A" : projHelper.ListUserProjects(user.Id).Select(p => p.Name).ToList() }; if (userVM.ProjectNames.Count() == 0) { userVM.ProjectNames.Add("N/A"); } myData.Add(userVM); } return(View(myData)); }
public ActionResult DevProjIndex() { //find the id of the current user string devUserId = User.Identity.GetUserId(); TicketIndexViewModel model = new TicketIndexViewModel(); //use roles helper to check for the roles ProjectsHelper phelper = new ProjectsHelper(); //user ProjectsHelper to get a list of projects the dev is on. List <Project> devProjects = phelper.ListUserProjects(devUserId).ToList(); //use linq with selectmany to get all tickets on each project. if (devProjects.Count() == 0) { return(RedirectToAction("Index")); } var devProjTickets = devProjects.SelectMany(t => t.Tickets).AsQueryable(); { var tickets = devProjTickets.Include(t => t.AssignedToUser) .Include(t => t.OwnerUser) .Include(t => t.Project) .Include(t => t.TicketPriority) .Include(t => t.TicketStatus) .Include(t => t.TicketType); //tickets = tickets.Where(t => t.Project.Id == phelper.ListUserProjects(devUserId).id; model.DevTickets = tickets.ToList(); } return(View(model)); }