Beispiel #1
0
        public ActionResult Index()
        {
            var tickets = db.Tickets.Include(t => t.Assignee).Include(t => t.Author).Include(t => t.Priority).Include(t => t.Project).Include(t => t.Type).Include(t => t.Status);
            var user    = db.Users.Find(User.Identity.GetUserId());
            UserRolesHelperClass rolesHelper = new UserRolesHelperClass(db);
            var userRoles = rolesHelper.ListUserRoles(user.Id);

            //if user is ADMIN, show all tickets
            if (userRoles.Contains("Admin"))
            {
                return(View(tickets.ToList()));
            }
            //if user is PM, show ticket for all PM
            if (userRoles.Contains("ProjectManager"))
            {
                return(View(user.Projects.SelectMany(t => t.Tickets).ToList()));
            }
            //if user is DEVELOPER, show all tickets assinged to Developer
            if (userRoles.Contains("Developer") && userRoles.Contains("Submitter"))
            {
                return(View(db.Tickets.Where(t => t.AssigneeId == user.Id || t.AuthorId == user.Id).ToList()));
            }

            if (userRoles.Contains("Developer"))
            {
                return(View(db.Tickets.Where(t => t.AssigneeId == user.Id).ToList()));
            }
            //if user is SUBMITTER, show all tickets he has submitted
            if (userRoles.Contains("Submitter"))
            {
                return(View(db.Tickets.Where(t => t.AuthorId == user.Id).ToList()));
            }
            return(View(tickets));
            //return RedirectToAction("Login", "Account");
        }
Beispiel #2
0
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            UserRolesHelperClass rolesHelper = new UserRolesHelperClass(db);
            var    user      = db.Users.Find(User.Identity.GetUserId());
            var    userRoles = rolesHelper.ListUserRoles(user.Id);
            Ticket ticket    = db.Tickets.Find(id);

            if (ticket == null)
            {
                return(HttpNotFound());
            }

            //Prevents URL HiJacking
            if (userRoles.Contains("Admin"))
            {
                return(View(ticket));
            }
            if (userRoles.Contains("ProjectManager"))
            {
                if (ticket.Project.Users.Contains(user))
                {
                    return(View(ticket));
                }
            }
            if (userRoles.Contains("Developer") && userRoles.Contains("Submitter"))
            {
                if (ticket.AssigneeId == user.Id)
                {
                    return(View(ticket));
                }
                if (ticket.AuthorId == user.Id)
                {
                    return(View(ticket));
                }
            }
            if (userRoles.Contains("Developer"))
            {
                if (ticket.AssigneeId == user.Id)
                {
                    return(View(ticket));
                }
            }
            if (userRoles.Contains("Submitter"))
            {
                if (ticket.AuthorId == user.Id)
                {
                    return(View(ticket));
                }
            }

            return(RedirectToAction("Login", "Account"));
        }
        public ActionResult Create(int?id)
        {
            var user = db.Users.Find(User.Identity.GetUserId());
            UserRolesHelperClass rolesHelper = new UserRolesHelperClass(db);
            var userRoles = rolesHelper.ListUserRoles(user.Id);

            ViewBag.UserId   = user.Id;
            ViewBag.TicketId = id;
            ViewBag.AuthorID = User.Identity.GetUserId();

            return(View());
        }
        public ActionResult AssignUserRoles(string id)
        {
            var user = db.Users.Find(id);
            AdminUserViewModel   AdminModel = new AdminUserViewModel();
            UserRolesHelperClass helper     = new UserRolesHelperClass(db);
            var currentRoles = helper.ListUserRoles(id);
            var absentRoles  = helper.ListAbsentUserRoles(id);

            AdminModel.Roles       = new MultiSelectList(currentRoles);
            AdminModel.AbsentRoles = new MultiSelectList(absentRoles);
            AdminModel.User        = user;

            return(View(AdminModel));
        }
Beispiel #5
0
        public ActionResult Edit(int?id)
        {
            UserRolesHelperClass rolesHelper = new UserRolesHelperClass(db);
            ProjectUserHelper    helper      = new ProjectUserHelper(db);
            var user      = db.Users.Find(User.Identity.GetUserId());
            var userRoles = rolesHelper.ListUserRoles(user.Id);
            var tickets   = db.Tickets.Include(t => t.Assignee).Include(t => t.Project).Include(t => t.Priority).Include(t => t.Status).Include(t => t.Type);

            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Ticket ticket = db.Tickets.Find(id);

            if (ticket == null)
            {
                return(HttpNotFound());
            }



            ViewBag.AssigneeId = new SelectList(rolesHelper.UsersInRole("Developer"), "Id", "DisplayName", ticket.AssigneeId);
            ViewBag.ProjectId  = new SelectList(helper.AssignedProjects(user.Id), "Id", "Title", ticket.ProjectId);
            ViewBag.PriorityId = new SelectList(db.Priorities, "Id", "Name", ticket.PriorityId);
            ViewBag.TypeId     = new SelectList(db.Types, "Id", "Name", ticket.TypeId);
            ViewBag.StatusId   = new SelectList(db.Status, "Id", "Name", ticket.StatusId);

            if (ticket == null)
            {
                return(HttpNotFound());
            }
            if (userRoles.Contains("ProjectManager"))
            {
                return(View(ticket));
            }
            if (userRoles.Contains("Admin"))
            {
                return(View(ticket));
            }
            if (userRoles.Contains("Developer"))
            {
                return(View(ticket));
            }
            if (userRoles.Contains("Submitter"))
            {
                return(View(ticket));
            }

            return(RedirectToAction("Login", "Account"));
        }
        public ActionResult Index()
        {
            var user = db.Users.Find(User.Identity.GetUserId());
            UserRolesHelperClass rolesHelper = new UserRolesHelperClass(db);
            var userRoles = rolesHelper.ListUserRoles(user.Id);

            if (userRoles.Contains("Admin"))
            {
                return(View(db.Projects.ToList()));
            }
            if (userRoles.Contains("ProjectManager") || (userRoles.Contains("Developer")) || (userRoles.Contains("Submitter")))
            {
                return(View(user.Projects.ToList()));
            }
            return(View(db.Projects.ToList()));
        }
Beispiel #7
0
        public ActionResult Index()
        {
            var user = db.Users.Find(User.Identity.GetUserId());
            UserRolesHelperClass rolesHelper = new UserRolesHelperClass(db);
            var userRoles = rolesHelper.ListUserRoles(user.Id);

            if (userRoles.Contains("Admin"))
            {
                return(View(db.Projects.ToList()));
            }
            if (userRoles.Contains("ProjectManager") || (userRoles.Contains("Developer")) || (userRoles.Contains("Submitter")))
            {
                return(View(user.Projects.ToList()));
                //if (userRoles.Contains("ProjectManager"))
                //{
                //    return View(db.Projects.Where(t => t.AssigneeId == user.Id).ToList());

                //}
                //return View("Index", "Tickets");
            }
            return(View(db.Projects.ToList()));
        }
Beispiel #8
0
        public ActionResult Edit(int?id)
        {
            UserRolesHelperClass rolesHelper = new UserRolesHelperClass(db);
            ProjectUserHelper    helper      = new ProjectUserHelper(db);
            var user      = db.Users.Find(User.Identity.GetUserId());
            var userRoles = rolesHelper.ListUserRoles(user.Id);
            var tickets   = db.Tickets.Include(t => t.Assignee).Include(t => t.Project).Include(t => t.Priority).Include(t => t.Status).Include(t => t.Type);

            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Ticket ticket = db.Tickets.Find(id);

            if (ticket == null)
            {
                return(HttpNotFound());
            }

            //Load up the Multi Select list with Developers only
            //var developers = new List<ApplicationUser>();
            //var allUsers = db.Users.ToList();
            //foreach (var person in allUsers)
            //{
            //    if (rolesHelper.IsUserInRole(person.Id, "Developer"))
            //    {
            //        developers.Add(person);
            //    }
            //}
            //ViewBag.AssignedToUserId = new SelectList(developers, "Id", "DisplayName", ticket.AssigneeId);

            ViewBag.AssigneeId = new SelectList(rolesHelper.UsersInRole("Developer"), "Id", "DisplayName", ticket.AssigneeId);
            ViewBag.ProjectId  = new SelectList(helper.AssignedProjects(user.Id), "Id", "Title", ticket.PriorityId);

            //ViewBag.AssigneeId = new SelectList(db.Users, "Id", "FirstName", ticket.AssigneeId);
            //ViewBag.AuthorId = new SelectList(db.Users, "Id", "FirstName", ticket.AuthorId);
            //ViewBag.AuthorId = user.FirstName;
            ViewBag.PriorityId = new SelectList(db.Priorities, "Id", "Name", ticket.PriorityId);
            //ViewBag.ProjectId = new SelectList(db.Projects, "Id", "Title", ticket.ProjectId);
            ViewBag.TypeId   = new SelectList(db.Types, "Id", "Name", ticket.TypeId);
            ViewBag.StatusId = new SelectList(db.Status, "Id", "Name", ticket.StatusId);

            if (ticket == null)
            {
                return(HttpNotFound());
            }
            if (userRoles.Contains("ProjectManager"))
            {
                return(View(ticket));
            }
            if (userRoles.Contains("Admin"))
            {
                return(View(ticket));
            }
            if (userRoles.Contains("Developer"))
            {
                return(View(ticket));
            }
            if (userRoles.Contains("Submitter"))
            {
                return(View(ticket));
            }

            return(RedirectToAction("Login", "Account"));
        }