Esempio n. 1
0
        public ActionResult AssignTicket(int?id)
        {
            UserRolesHelper helper = new UserRolesHelper();
            var             ticket = db.Tickets.Find(id);
            var             users  = helper.UsersInRole("DEVELOPER").ToList();

            ViewBag.AssignedToUserId = new SelectList(users, "Id", "FullNameWithEmail", ticket.AssignedToUserId);
            return(View(ticket));
        }
Esempio n. 2
0
        public ActionResult EditUser(string Id = "d86f73dd-96c6-437b-9107-58598036da56")
        {
            var user = db.Users.Find(Id);
            Models.AdminUserViewModel AdminModel = new Models.AdminUserViewModel() { User = user };
            UserRolesHelper UserHelper = new UserRolesHelper();
            var selected = UserHelper.ListUserRoles(Id);
            AdminModel.Roles = new MultiSelectList(db.Roles.ToList(), "Name", "Name", selected);
            AdminModel.User = user;

            return View(AdminModel);
        }
Esempio n. 3
0
        public IList <ApplicationUser> DevelopersNotOnProject(int projectId, string roleName)
        {
            var userList    = new List <ApplicationUser>();
            var rolesHelper = new UserRolesHelper();

            foreach (var user in db.Users)
            {
                if (!this.IsProjectDeveloper(user.Id, projectId) && rolesHelper.IsUserInRole(user.Id, roleName))
                {
                    userList.Add(user);
                }
            }
            return(userList);
        }
Esempio n. 4
0
        public IList <ApplicationUser> UsersOnProject(int projectId, string roleName)
        {
            var resultList  = new List <ApplicationUser>();
            var rolesHelper = new UserRolesHelper();

            foreach (var user in db.Projects.Find(projectId).Users)
            {
                if (rolesHelper.IsUserInRole(user.Id, roleName))
                {
                    resultList.Add(user);
                }
            }
            return(resultList);
        }
Esempio n. 5
0
        public ActionResult EditUser(string Id, Models.AdminUserViewModel model)
        {
            UserRolesHelper helper = new UserRolesHelper();
            foreach(var role in db.Roles.ToList())
            {
                if (model.SelectedRoles.Contains(role.Name))
                {
                    helper.AddUserToRole(model.User.Id, role.Name);
                }
                else
                    helper.RemoveUserFromRole(model.User.Id, role.Name);
            }

            return RedirectToAction("Index", new { model.User.Id });
        }
Esempio n. 6
0
        public string GetUserRole(string currentUserId)
        {
            UserRolesHelper uRoleHelper = new UserRolesHelper();
            string          role        = "Submitter";

            //string currentUserId = User.Identity.GetUserId();
            if (currentUserId != null)
            {
                var roles = uRoleHelper.ListUserRoles(currentUserId).OrderBy(s => s);
                foreach (string myRole in roles)
                {
                    if (myRole == "Admin")
                    {
                        role = "Admin";
                        break;
                    }
                    else if (myRole == "Developer")
                    {
                        role = "Developer";
                        break;
                    }
                    else if (myRole == "Project Manager")
                    {
                        role = "Manager";
                        break;
                    }
                    else
                    {
                        role = "Submitter";
                        break;
                    }
                }
            }
            else
            {
                role = "Submitter";
            }

            return(role);
        }
Esempio n. 7
0
        public ActionResult Edit(int? id)
        {
            if (id == null)
            {
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            }
            Tickets tickets = db.Tickets.Find(id);
            if (tickets == null)
            {
                return HttpNotFound();
            }

            var project = db.Projects.Find(tickets.ProjectId);
            var projUser = project.Users.ToList();
            List<ApplicationUser> projdevs = new List<ApplicationUser>();
            foreach (var user in projUser)
            {
                UserRolesHelper helper = new UserRolesHelper();
                if (helper.IsUserInRole(user.Id, "Developer"))
                {
                    projdevs.Add(user);
                }
            }
            ViewBag.ProjectId = new SelectList(db.Projects, "Id", "Name", tickets.ProjectId);
            ViewBag.TicketPriorityId = new SelectList(db.TicketPriorities, "Id", "Name", tickets.TicketPriorityId);
            ViewBag.TicketStatusId = new SelectList(db.TicketStatus, "Id", "Name", tickets.TicketStatusId);
            ViewBag.TicketTypeId = new SelectList(db.TicketType, "Id", "Name", tickets.TicketTypeId);
            ViewBag.AssignedToUserId = new SelectList(projdevs, "Id", "FirstName", tickets.AssignedToUserId);

            return View(tickets);
        }