Example #1
0
        //public ICollection<ApplicationUser> UsersNotOnTicket()
        //{
        //    var userId = db.Users.ToString();
        //    return db.Tickets.Where(t => t.Users.All(u => u.Id != userId)).ToList();
        //    return db.Users.Where(u => u.Tickets.All(p => p.Id != ticketId)).ToList();

        //}

        public ICollection <string> GetTicketUserRoles(string roleName, int ticketId)
        {
            var users       = UsersOnTicket(ticketId);
            var usersInRole = new List <string>();
            var roleHelper  = new UserRolesHelper();

            foreach (var user in users)
            {
                if (roleHelper.IsUserInRole(user.Id, roleName))
                {
                    usersInRole.Add(user.FirstName + " " + user.LastName);
                }
            }
            return(usersInRole);
        }
Example #2
0
        public ICollection <string> GetProjectUserRoles(string roleName, int projectId)
        {
            var users       = UsersOnProject(projectId);
            var usersInRole = new List <string>();
            var roleHelper  = new UserRolesHelper();

            foreach (var user in users)
            {
                if (roleHelper.IsUserInRole(user.Id, roleName))
                {
                    usersInRole.Add(user.Email);
                }
            }
            return(usersInRole);
        }
Example #3
0
        public ICollection <ApplicationUser> UsersOnProjectByRole(int projectId, string roleName)
        {
            var roleHelper   = new UserRolesHelper();
            var projectUsers = new List <ApplicationUser>();
            var users        = UsersOnProject(projectId);

            foreach (var user in users)
            {
                if (roleHelper.ListUserRoles(user.Id).FirstOrDefault() == roleName)
                {
                    projectUsers.Add(user);
                }
            }
            return(projectUsers);
        }
Example #4
0
        public List <UserInfoViewModel> getUserInfo(List <string> userIds)
        {
            //set up a list to contain user info objects
            var userInfoList = new List <UserInfoViewModel>();

            foreach (var userId in userIds)
            {
                var myUser = new UserInfoViewModel();
                myUser.UserId = userId;
                var appUser = db.Users.Find(userId);
                myUser.FirstName = appUser.FirstName;
                myUser.LastName  = appUser.LastName;
                myUser.Email     = appUser.Email;
                myUser.UserName  = myUser.FirstName + " " + myUser.LastName;
                var myUserHelper = new UserRolesHelper();
                myUser.CurrentRoles = myUserHelper.ListUserRoles(userId);
                userInfoList.Add(myUser);
            }
            return(userInfoList);
        }
Example #5
0
        public void NewTicketNotification(Projects currentProject, ApplicationUser formSubmitter, DateTimeOffset timeStamp, TicketPost newticket)
        {
            //UserRoles Helper
            var userRolesHelper          = new UserRolesHelper(db);
            var project                  = db.Projects.Find(currentProject.Id);
            var allProjectManagers       = userRolesHelper.GetAllUsersInRole("Project Manager").ToList();
            var projectManagersInProject = allProjectManagers.Where(u => u.Projects.Contains(project)).ToList();

            //Notify all PMs that a new ticket has been created on their Project
            foreach (var item in projectManagersInProject)
            {
                var newTicketNotification = new TicketNotification();
                newTicketNotification.Notification =
                    " Has added a New Ticket(#" + newticket.Id + ") on Project(#" + currentProject.Id + "): " + currentProject.Name +
                    ", Ticket Priority: " + GetPriorityName(newticket.TicketPriorityID);
                newTicketNotification.TriggeredByUserId = formSubmitter.Id;
                newTicketNotification.TicketID          = newticket.Id;
                newTicketNotification.Created           = timeStamp;
                newTicketNotification.UserID            = item.Id;
                db.TicketNotifications.Add(newTicketNotification);
                //Save Ticket Notification
                db.SaveChanges();
            }
        }
Example #6
0
 public TicketsHelper(UserRolesHelper urh, ApplicationDbContext db)
 {
     roleHelper = urh;
     context    = db;
 }