public ActionResult ManageUserRole(string userId) { //How do i load up a dropdown list with role info //new SelectList(the list of data pushed into control) //what column is used to transmit my selection to user, // the column that we show to the user inside control, // if role already occuppied Show this () var currentRole = roleHelper.ListUserRoles(userId).FirstOrDefault(); ViewBag.UserId = userId; ViewBag.Roles = new SelectList(db.Roles.ToList(), "Name", "Name", currentRole); return(View()); }
public static bool TicketDetailIsViewableByUser(int TicketId) { var userId = HttpContext.Current.User.Identity.GetUserId(); var roleName = roleHelp.ListUserRoles(userId).FirstOrDefault(); var systemRole = (SystemRole)Enum.Parse(typeof(SystemRole), roleName); switch (systemRole) { case SystemRole.Admin: break; case SystemRole.ProjectManager: break; case SystemRole.Developer: break; case SystemRole.Submitter: break; } return(true); }
public ActionResult MyIndex() { var userId = User.Identity.GetUserId(); var myRole = roleHelp.ListUserRoles(userId).FirstOrDefault(); var myTickets = new List <Ticket>(); switch (myRole) { case "Developer": myTickets = db.Tickets.Where(t => t.AssignedToUserId == userId).ToList(); break; case "submitter": myTickets = db.Tickets.Where(t => t.OwnerUserId == userId).ToList(); break; case "ProjectManager": myTickets = db.Users.Find(userId).Projects.SelectMany(t => t.Tickets).ToList(); break; } return(View("Index", myTickets)); }