Exemple #1
0
        public ActionResult ManageProjectUsers(int projectId, string projectManagerId, List <string> developers, List <string> submitters)
        {
            foreach (var user in projectHelper.UsersOnProject(projectId).ToList())
            {
                projectHelper.RemoveUserFromProject(user.Id, projectId);
            }

            //In order to ensure that I always have the correct and current set of assign users
            //I will first remove all users from the project and then I will add back the selected users

            if (!string.IsNullOrEmpty(projectManagerId))
            {
                projectHelper.AddUserToProject(projectManagerId, projectId);
            }
            if (developers != null)
            {
                foreach (var developerId in developers)
                {
                    projectHelper.AddUserToProject(developerId, projectId);
                }
            }
            if (submitters != null)
            {
                foreach (var submitterId in submitters)
                {
                    projectHelper.AddUserToProject(submitterId, projectId);
                }
            }
            return(RedirectToAction("ManageProjectUsers", new { id = projectId }));
        }
Exemple #2
0
        public ActionResult ManageProjectUsers(string managerId, List <string> developerIds, List <string> submitterIds, int projectId)
        {
            //foreach (var projectId in projectId)
            //{
            if (!string.IsNullOrEmpty(managerId))
            {
                //if (!projHelper.IsUserOnProject(managerId, projectId.Value))
                projHelper.AddProjectManager(managerId, projectId);
            }

            if (developerIds != null)
            {
                foreach (var devId in developerIds)
                {
                    if (!projHelper.IsUserOnProject(devId, projectId))
                    {
                        projHelper.AddUserToProject(devId, projectId);
                    }
                }
            }

            if (submitterIds != null)
            {
                foreach (var submitterId in submitterIds)
                {
                    if (!projHelper.IsUserOnProject(submitterId, projectId))
                    {
                        projHelper.AddUserToProject(submitterId, projectId);
                    }
                }
            }
            //}

            return(Redirect(Request.UrlReferrer.ToString()));
        }
Exemple #3
0
        public ActionResult ManageUsers(int projectId, string adminId, string projectManagerId, List <string> developers, List <string> submitters)
        {
            foreach (var user in projectHelper.UsersOnProject(projectId).ToList())
            {
                projectHelper.RemoveUserFromProject(user.Id, projectId);
            }

            if (!string.IsNullOrEmpty(adminId))
            {
                projectHelper.AddUserToProject(adminId, projectId);
            }
            if (!string.IsNullOrEmpty(projectManagerId))
            {
                projectHelper.AddUserToProject(projectManagerId, projectId);
            }
            if (developers != null)
            {
                foreach (var developerId in developers)
                {
                    projectHelper.AddUserToProject(developerId, projectId);
                }
            }
            if (submitters != null)
            {
                foreach (var submitterId in submitters)
                {
                    projectHelper.AddUserToProject(submitterId, projectId);
                }
            }

            return(RedirectToAction("ManageUsers", new { id = projectId }));
        }
Exemple #4
0
        public ActionResult ManageUsers(int projectId, string projectManagerId, List <string> developers, List <string> submitters)
        {
            var userId = User.Identity.GetUserId();

            foreach (var user in projectHelper.UsersOnProject(projectId).ToList())
            {
                projectHelper.RemoveUserFromProject(user.Id, projectId);
            }
            if (string.IsNullOrEmpty(projectManagerId))
            {
                projectHelper.AddUserToProject(userId, projectId);
            }

            if (!string.IsNullOrEmpty(projectManagerId))
            {
                projectHelper.AddUserToProject(projectManagerId, projectId);
            }
            if (developers != null)
            {
                foreach (var developerId in developers)
                {
                    projectHelper.AddUserToProject(developerId, projectId);
                }
            }
            if (submitters != null)
            {
                foreach (var submitterId in submitters)
                {
                    projectHelper.AddUserToProject(submitterId, projectId);
                }
            }

            return(RedirectToAction("Index", "Projects"));
        }
 public ActionResult AssignUsers(int projectId, List <string> UnassignedUsers)
 {
     if (UnassignedUsers == null)
     {
         return(RedirectToAction("Index", "Projects"));
     }
     foreach (var userId in UnassignedUsers)
     {
         ph.AddUserToProject(userId, projectId);
     }
     return(RedirectToAction("Index", "Projects"));
 }
        public ActionResult ProjectWizard(ProjectWizardVM model)
        {
            ViewBag.Errors = "";
            if (model.ProjectManagerId == null)
            {
                ViewBag.Errors += "<p>You must select a project Manager</p>";
            }
            if (model.DeveloperIds.Count == 0)
            {
                ViewBag.Errors += "<p>You must select at least one Developer</p>";
            }
            if (model.SubmitterIds.Count == 0)
            {
                ViewBag.Errors += "<p>You must select at least one Submitter</p>";
            }
            if (ViewBag.Errors.Length > 0)
            {
                ViewBag.ProjectManagerId = new SelectList(roleHelper.UsersInRole("ProjectManager"), "Id", "FullName");
                ViewBag.DeveloperIds     = new MultiSelectList(roleHelper.UsersInRole("Developer"), "Id", "FullName");
                ViewBag.SubmitterIds     = new MultiSelectList(roleHelper.UsersInRole("Submitter"), "Id", "FullName");
                return(RedirectToAction("Index", "Home"));
            }
            if (ModelState.IsValid)
            {
                Project project = new Project();
                project.Name       = model.Name;
                project.IsArchived = false;
                project.Created    = DateTime.Now;
                db.Projects.Add(project);
                db.SaveChanges();

                projectHelper.AddUserToProject(model.ProjectManagerId, project.Id);
                foreach (var userId in model.DeveloperIds)
                {
                    projectHelper.AddUserToProject(userId, project.Id);
                }
                foreach (var userId in model.SubmitterIds)
                {
                    projectHelper.AddUserToProject(userId, project.Id);
                }

                return(RedirectToAction("Details", "Projects", new { project.Id }));
            }
            else
            {
                ViewBag.ProjectManagerId = new SelectList(roleHelper.UsersInRole("ProjectManager"), "Id", "FullName");
                ViewBag.DeveloperIds     = new MultiSelectList(roleHelper.UsersInRole("Developer"), "Id", "FullName");
                ViewBag.SubmitterIds     = new MultiSelectList(roleHelper.UsersInRole("Submitter"), "Id", "FullName");
                return(View(model));
            }
        }
Exemple #7
0
        public ActionResult Create([Bind(Include = "Id,Name")] Project project)
        {
            if (ModelState.IsValid)
            {
                project.Created    = DateTime.Now;
                project.IsArchived = false;
                db.Projects.Add(project);
                db.SaveChanges();
                projectHelper.AddUserToProject(User.Identity.GetUserId(), project.Id);
                return(RedirectToAction("Index"));
            }

            return(View(project));
        }
Exemple #8
0
        public ActionResult ManageUserProjects(string userId, List <int> projects)
        {
            foreach (var project in projectHelper.ListUserProjects(userId).ToList())
            {
                projectHelper.RemoveUserFromProject(userId, project.Id);
            }
            if (projects != null)
            {
                foreach (var projectId in projects)

                {
                    projectHelper.AddUserToProject(userId, projectId);
                }
            }
            return(RedirectToAction("UserIndex"));
        }
Exemple #9
0
        public ActionResult ManageUsers(List <string> userIds, int manageUsers) //Every id except user is a int
        {
            //  Step1: unassign any user from any role they could be assigned.

            foreach (var userId in userIds) //looks at al the people i have selected in multilist
            {
                //What is the role of this person?
                var userProject = projectHelper.ListUserProjects(userId).FirstOrDefault(); //finds them one at a time to assign them their one and only role
                if (userProject != null)                                                   //if do occupy a role
                {
                    projectHelper.RemoveUserFromProject(userId, manageUsers);              //remove them from that role
                }
            }


            //Step2: add them back to selected role
            if (manageUsers != 0)
            {
                foreach (var userId in userIds)
                {
                    projectHelper.AddUserToProject(userId, manageUsers);
                }
            }

            return(RedirectToAction("ManageUsers", "Admin"));
        }
        public ActionResult ManageProjectUsers(List <string> userIds, List <int> projectIds)
        {
            // If no users and/or no projects selected send them back to this page
            if (userIds == null || projectIds == null)
            {
                return(RedirectToAction("ManageProjectUsers"));
            }
            foreach (var userId in userIds)
            {
                foreach (var projectId in projectIds)
                {
                    projectHelper.AddUserToProject(userId, projectId);
                }
            }

            return(RedirectToAction("ManageProjectUsers"));
        }
        public ActionResult ManageUserProjects(List <int> projects, string userId)
        {
            foreach (var project in projectHelper.ListUserProjects(userId).ToList())
            {
                projectHelper.RemoveUserFromProject(userId, project.Id);
            }

            //if the incoming list is not null we will reassign them to all that are selected
            if (projects != null)
            {
                foreach (var projectId in projects)
                {
                    projectHelper.AddUserToProject(userId, projectId);
                }
            }
            return(RedirectToAction("Index", "Projects"));
        }
Exemple #12
0
 public ActionResult ManageUserProjectAssignments(List <string> userIds, List <int> projectIds, bool addUser)
 {
     if (userIds == null || projectIds == null)
     {
         TempData["InvalidSelection"] = "Please select both a user and a project";
     }
     else
     {
         foreach (var userId in userIds)
         {
             foreach (var projectId in projectIds)
             {
                 if (addUser)
                 {
                     projHelper.AddUserToProject(userId, projectId);
                 }
                 else
                 {
                     projHelper.RemoveUserFromProject(userId, projectId);
                 }
             }
         }
     }
     return(RedirectToAction("ManageUserProjectAssignments"));
 }
        public ActionResult AddUserToProject(string userId, int projId)
        {
            ProjectHelper helper = new ProjectHelper();
            var           user   = db.Users.Find(userId);

            helper.AddUserToProject(user.Id, projId);

            return(RedirectToAction("Index", new { id = projId }));
        }
Exemple #14
0
        public ActionResult Edit([Bind(Include = "Id,Name,Description")] Project project, List <string> Developers, List <string> Submitters, string PM)
        {
            if (ModelState.IsValid)
            {
                var oldUsersOnProject = projectHelper.UsersOnProject(project.Id).ToList();

                //unassign everyone from the project. must be ToList so the foreach loop doesnt constantly modify itself over an over
                foreach (var user in projectHelper.UsersOnProject(project.Id).ToList())
                {
                    projectHelper.RemoveUserFromProject(user.Id, project.Id);
                }

                //add back to the project all the selected developers
                if (Developers != null)
                {
                    foreach (var userId in Developers)
                    {
                        projectHelper.AddUserToProject(userId, project.Id);
                    }
                }

                //add back to the project all the selected submitters
                if (Submitters != null)
                {
                    foreach (var userId in Submitters)
                    {
                        projectHelper.AddUserToProject(userId, project.Id);
                    }
                }

                //add back to the project the selected PM
                if (PM != null)
                {
                    projectHelper.AddUserToProject(PM, project.Id);
                }

                projectNotificationHelper.TriggerProjectAssignmentNotifications(oldUsersOnProject, project.Id);

                db.Entry(project).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            return(View(project));
        }
        public ActionResult AddedToProject(int projects, string PMAddedToProject)
        {
            var pj      = db.Projects.Find(projects);
            var phelper = new ProjectHelper();

            phelper.AddUserToProject(PMAddedToProject, projects);
            pj.ProjectManager = PMAddedToProject;
            db.SaveChanges();

            return(RedirectToAction("ManageRoles"));
        }
Exemple #16
0
        public ActionResult Edit([Bind(Include = "Id,Name")] Project project, List <string> Developers, List <string> Submitters, string ProjectManager)
        {
            if (ModelState.IsValid)
            {
                //Unassign EVERYONE from the project
                foreach (var user in projectHelper.UsersOnProject(project.Id).ToList())
                {
                    projectHelper.RemoveUserFromProject(user.Id, project.Id);
                }

                //Add back to the project all the selected Developers
                if (Developers != null)
                {
                    foreach (var userId in Developers)
                    {
                        projectHelper.AddUserToProject(userId, project.Id);
                    }
                }

                //Add back to the project all the selected Submitters
                if (Submitters != null)
                {
                    foreach (var userId in Submitters)
                    {
                        projectHelper.AddUserToProject(userId, project.Id);
                    }
                }

                //Add back to the project all the selected Project Manager
                if (ProjectManager != null)
                {
                    projectHelper.AddUserToProject(ProjectManager, project.Id);
                }


                db.Entry(project).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("MyIndex"));
            }
            return(View(project));
        }
        public ActionResult ManageProjectsUsers(List <int> projects, string projectManagerId, List <string> developers, List <string> submitters)
        {
            //Remove users from every project I have selected
            if (projects != null)
            {
                foreach (var projectId in projects)
                {
                    //Remove everone from this project
                    foreach (var user in projHelper.UsersOnProject(projectId).ToList())
                    {
                        projHelper.RemoveUserFromProject(user.Id, projectId);
                    }

                    //add back project manager to list if chose manager
                    if (!string.IsNullOrEmpty(projectManagerId))
                    {
                        projHelper.AddUserToProject(projectManagerId, projectId);
                    }

                    if (developers != null)
                    {
                        foreach (var developerId in developers)
                        {
                            projHelper.AddUserToProject(developerId, projectId);
                        }
                    }

                    if (submitters != null)
                    {
                        foreach (var submittersId in submitters)
                        {
                            projHelper.AddUserToProject(submittersId, projectId);
                        }
                    }
                }
            }

            return(RedirectToAction("ManageProjectsUsers"));
        }
        public ActionResult Create([Bind(Include = "Id,Name,Created,Description,IsArchived")] Project project)
        {
            if (ModelState.IsValid)
            {
                project.Created = DateTime.Now;
                db.Projects.Add(project);
                db.SaveChanges();
                projectHelper.AddUserToProject(User.Identity.GetUserId(), project.Id);//Added 8/31/2020
                return RedirectToAction("Index");
            }

            return View(project);
        }
        public ActionResult ProjectCreate(Project project, List <string> Developers, List <string> Submitters)
        {
            if (ModelState.IsValid)
            {
                db.Projects.Add(project);
                db.SaveChanges();

                foreach (var dev in Developers)
                {
                    projHelper.AddUserToProject(dev, project.Id);
                }
                foreach (var sub in Submitters)
                {
                    projHelper.AddUserToProject(sub, project.Id);
                }
                projHelper.AddUserToProject(User.Identity.GetUserId(), project.Id);


                return(RedirectToAction("Index"));
            }

            return(View(project));
        }
Exemple #20
0
 public ActionResult ManageProjectUsers(List <string> userIds, int projectId)
 {
     if (userIds == null)
     {
         return(RedirectToAction("ManageProjectUsers"));
     }
     foreach (var userId in userIds)
     {
         if (userId != null)
         {
             projectHelper.AddUserToProject(userId, projectId);
         }
     }
     ViewBag.UserIds = new MultiSelectList(projectHelper.ListUsersNotOnProject(projectId), "Id", "FullName");
     return(RedirectToAction("Details", "Projects", new { id = projectId }));
 }
        public ActionResult ManageProjectUsers(List <string> userIds, List <int> projectIds)
        {
            if (userIds == null || projectIds == null)
            {
                return(RedirectToAction("ManageProjectUsers"));
            }

            foreach (var userId in userIds)
            {
                foreach (var projectId in projectIds)
                {
                    projectHelper.AddUserToProject(userId, projectId);
                }
            }

            return(RedirectToAction("ManageProjectUsers"));
        }
        public ActionResult EditProjectUser([Bind(Include = "Id, Name, User, Projects, SelectedUsers, TempUrl")] AdminProjectViewModel model)
        {
            var           prjId  = model.Projects.Id;
            ProjectHelper helper = new ProjectHelper();

            foreach (var userRemove in db.Users.Select(u => u.FullName).ToList())
            {
                helper.RemoveUserToProject(userRemove, prjId);
            }
            foreach (var userAdd in model.SelectedUsers)
            {
                helper.AddUserToProject(userAdd, prjId);
            }
            //return Redirect(Request.UrlReferrer.ToString());
            //return RedirectToRoute(model.TempUrl);
            return(RedirectToAction("Index", "Projects"));
        }
Exemple #23
0
        public ActionResult ManageAssignments(List <string> userIds, List <int> projectIds)
        {
            var projectHelper = new ProjectHelper();

            if (userIds == null || projectIds == null)
            {
                return(RedirectToAction("ManageAssignments"));
            }
            foreach (var user in userIds)
            {
                foreach (var project in projectIds)
                {
                    projectHelper.AddUserToProject(user, project);
                }
            }
            return(RedirectToAction("ManageAssignments"));
        }
Exemple #24
0
        public ActionResult AssignDev(ProjectDevViewModel model)
        {
            ProjectHelper ph = new ProjectHelper();

            if (ModelState.IsValid)
            {
                var prj = db.Projects.Find(model.project.Id);
                foreach (var usr in prj.Users)
                {
                    ph.RemoveUserFromProject(usr.Id, prj.Id);
                }

                foreach (var dev in model.SelectedUsers)
                {
                    ph.AddUserToProject(dev, model.project.Id);
                }
            }
            return(RedirectToAction("Details", new { id = model.project.Id }));
        }
Exemple #25
0
        public ActionResult AssignProjects(string UserId, List <int> AllProjects)
        {
            ProjectHelper projectHelper = new ProjectHelper();

            //First use the Project helper to remove this user from all Projects
            foreach (var project in projectHelper.ListUserProjects(UserId))
            {
                projectHelper.RemoveUserFromProject(UserId, project.Id);
            }

            //Next add the user to the selected Projects (AllProjects)
            if (AllProjects != null)
            {
                foreach (var projectId in AllProjects)
                {
                    projectHelper.AddUserToProject(UserId, projectId);
                }
            }
            return(RedirectToAction("AssignRoles", "Admin"));
        }
Exemple #26
0
        public ActionResult ManageProjectUsers(List <string> userIds, List <int> projectIds, bool assignRemove)
        {
            //Case 1: No Users and No Projects
            if (userIds == null || projectIds == null)
            {
                return(RedirectToAction("ManageProjectUsers"));
            }
            if (assignRemove)
            {
                //Iterate over each User and add them to each of the projects

                foreach (var userId in userIds)
                {
                    //Assign this person to each project
                    foreach (var projectId in projectIds)
                    {
                        projectHelper.AddUserToProject(userId, projectId);
                    }
                }
                TempData["Message"] = "Role has been successfully updated!";
                return(RedirectToAction("ManageProjectUsers"));
            }
            else
            {
                foreach (var userId in userIds)
                {
                    //Remove this person from each project
                    foreach (var projectId in projectIds)
                    {
                        projectHelper.RemoveUserFromProject(userId, projectId);
                    }
                }
                TempData["Message"] = "Role has been successfully updated!";
                return(RedirectToAction("ManageProjectUsers"));
            }
        }
Exemple #27
0
        public async Task <ActionResult> UpdateUsers(string ProjectManagers, List <string> Developers, List <string> Submitters, int projectId)
        {
            var project = db.Projects.Find(projectId);

            foreach (var user in project.Users)
            {
                await projHelper.RemoveUserFromProject(user.Id, projectId);
            }
            projHelper.AddUserToProject(ProjectManagers, projectId);
            foreach (var user in Developers)
            {
                projHelper.AddUserToProject(user, projectId);
            }
            foreach (var user in Submitters)
            {
                projHelper.AddUserToProject(user, projectId);
            }
            TempData["Message"] = "Project Users Updated Successfully.";
            return(RedirectToAction("Dashboard"));
        }
        public ActionResult Create([Bind(Include = "Id,Name,Description,CompletionDate")] Project project, string ProjectManager)
        {
            if (project.CompletionDate > DateTime.Now)
            {
                var projUsers = new List <ApplicationUser>();

                if (ModelState.IsValid)
                {
                    db.Projects.Add(project);
                    project.Created         = DateTime.Now;
                    project.ProjectStatusId = db.ProjectStatuses.FirstOrDefault(p => p.Status == "New").Id;
                    db.SaveChanges();
                    projHelper.AddUserToProject(ProjectManager, project.Id);

                    //project.CompletionDate = project.Created.AddDays(7);

                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
            }
            ViewBag.ProjectManager = new SelectList(roleHelper.UsersInRole("Project Manager"), "Id", "FirstName");

            return(View(project));
        }
Exemple #29
0
        protected override void Seed(BugTracker.Models.ApplicationDbContext context)
        {
            UserRoleHelper roleHelper    = new UserRoleHelper();
            ProjectHelper  projectHelper = new ProjectHelper();
            TicketHelper   ticketHelper  = new TicketHelper();
            SeedHelper     seedHelper    = new SeedHelper();
            var            rand          = new Random();

            #region User Roles

            var roleManager = new RoleManager <IdentityRole>(
                new RoleStore <IdentityRole>(context));
            if (!context.Roles.Any(r => r.Name == "Admin"))
            {
                roleManager.Create(new IdentityRole {
                    Name = "Admin"
                });
            }
            if (!context.Roles.Any(r => r.Name == "Moderator"))
            {
                roleManager.Create(new IdentityRole {
                    Name = "Moderator"
                });
            }
            if (!context.Roles.Any(r => r.Name == "ProjectManager"))
            {
                roleManager.Create(new IdentityRole {
                    Name = "ProjectManager"
                });
            }
            if (!context.Roles.Any(r => r.Name == "Submitter"))
            {
                roleManager.Create(new IdentityRole {
                    Name = "Submitter"
                });
            }
            if (!context.Roles.Any(r => r.Name == "Developer"))
            {
                roleManager.Create(new IdentityRole {
                    Name = "Developer"
                });
            }
            if (!context.Roles.Any(r => r.Name == "No-Role"))
            {
                roleManager.Create(new IdentityRole {
                    Name = "Default"
                });
            }
            #endregion
            #region demo-roles
            if (!context.Roles.Any(r => r.Name == "Demo-Admin"))
            {
                roleManager.Create(new IdentityRole {
                    Name = "Demo-Admin"
                });
            }
            if (!context.Roles.Any(r => r.Name == "Demo-Moderator"))
            {
                roleManager.Create(new IdentityRole {
                    Name = "Demo-Moderator"
                });
            }
            if (!context.Roles.Any(r => r.Name == "Demo-ProjectManager"))
            {
                roleManager.Create(new IdentityRole {
                    Name = "Demo-ProjectManager"
                });
            }
            if (!context.Roles.Any(r => r.Name == "Demo-Submitter"))
            {
                roleManager.Create(new IdentityRole {
                    Name = "Demo-Submitter"
                });
            }
            if (!context.Roles.Any(r => r.Name == "Demo-Developer"))
            {
                roleManager.Create(new IdentityRole {
                    Name = "Demo-Developer"
                });
            }
            #endregion
            context.SaveChanges();
            #region TicketType Seed
            context.TicketTypes.AddOrUpdate(
                tt => tt.Name,
                new TicketType()
            {
                Name = "Software"
            },
                new TicketType()
            {
                Name = "Hardware"
            },
                new TicketType()
            {
                Name = "UI"
            },
                new TicketType()
            {
                Name = "Defect"
            },
                new TicketType()
            {
                Name = "Feature Request"
            },
                new TicketType()
            {
                Name = "Other"
            }
                );

            #endregion
            #region TicketPriority Seed
            context.TicketPriorities.AddOrUpdate(
                tp => tp.Name,
                new TicketPriority()
            {
                Name = "Low"
            },
                new TicketPriority()
            {
                Name = "Medium"
            },
                new TicketPriority()
            {
                Name = "High"
            },
                new TicketPriority()
            {
                Name = "On Hold"
            }
                );
            #endregion
            #region TicketStatus Seed
            context.TicketStatuses.AddOrUpdate(
                ts => ts.Name,
                new TicketStatus()
            {
                Name = "Open"
            },
                new TicketStatus()
            {
                Name = "Assigned"
            },
                new TicketStatus()
            {
                Name = "Resolved"
            },
                new TicketStatus()
            {
                Name = "Reopened"
            },
                new TicketStatus()
            {
                Name = "Archived"
            }
                );
            #endregion
            #region Project Seed
            context.Projects.AddOrUpdate(
                p => p.Name,
                new Project()
            {
                Name = "User Interface for Banking", Created = DateTime.Now.AddDays(-60), DueDate = DateTime.Now.AddDays(-10), IsArchive = true
            },
                new Project()
            {
                Name = "Commercial Blog Site", Created = DateTime.Now.AddDays(-10), DueDate = DateTime.Now.AddDays(+100)
            },
                new Project()
            {
                Name = "Financial API", Created = DateTime.Now.AddDays(-45), DueDate = DateTime.Now.AddDays(+100)
            },
                new Project()
            {
                Name = "Sunset Light calculator", Created = DateTime.Now.AddDays(-30), DueDate = DateTime.Now.AddDays(+100)
            },
                new Project()
            {
                Name = "Factorial Calculator", Created = DateTime.Now.AddDays(-4), DueDate = DateTime.Now.AddDays(+100)
            },
                new Project()
            {
                Name = "Movie Comparer", Created = DateTime.Now.AddDays(-60), DueDate = DateTime.Now.AddDays(-10), IsArchive = true
            },
                new Project()
            {
                Name = "Fizz Buzz", Created = DateTime.Now.AddDays(-10), DueDate = DateTime.Now.AddDays(+100)
            },
                new Project()
            {
                Name = "Tacos and Cats", Created = DateTime.Now.AddDays(-45), DueDate = DateTime.Now.AddDays(+100)
            },
                new Project()
            {
                Name = "Fear the sums", Created = DateTime.Now.AddDays(-30), DueDate = DateTime.Now.AddDays(+100)
            },
                new Project()
            {
                Name = "Finacial portal", Created = DateTime.Now.AddDays(-4), DueDate = DateTime.Now.AddDays(+100)
            }
                );
            #endregion
            context.SaveChanges();
            #region user seed
            var userManager = new UserManager <ApplicationUser>(
                new UserStore <ApplicationUser>(context));
            if (!context.Users.Any(u => u.Email == "*****@*****.**"))
            {
                userManager.Create(new ApplicationUser()
                {
                    Email       = "*****@*****.**",
                    UserName    = "******",
                    FirstName   = "Andrew",
                    LastName    = "Russell",
                    AvatarPath  = "/Avatars/DemoUserAvatars/1.jpg",
                    PhoneNumber = "(111)111-1111"
                },
                                   "HelloNurse!");
            }
            var userId = userManager.FindByEmail("*****@*****.**").Id;
            userManager.AddToRole(userId, "ProjectManager");


            if (!context.Users.Any(u => u.Email == "*****@*****.**"))
            {
                userManager.Create(new ApplicationUser()
                {
                    Email       = "*****@*****.**",
                    UserName    = "******",
                    FirstName   = "Thomas",
                    LastName    = "Zanis",
                    AvatarPath  = "/Avatars/DemoUserAvatars/2.jpg",
                    PhoneNumber = RandomPhoneNumber(),
                    Description = "Administrator of the Site"
                },
                                   "Tobeornot123!");
            }
            userId = userManager.FindByEmail("*****@*****.**").Id;
            userManager.AddToRole(userId, "Admin");


            if (!context.Users.Any(u => u.Email == "*****@*****.**"))
            {
                userManager.Create(new ApplicationUser()
                {
                    Email       = "*****@*****.**",
                    UserName    = "******",
                    FirstName   = "Admin",
                    LastName    = "Demo",
                    AvatarPath  = "/Avatars/DemoUserAvatars/3.jpg",
                    PhoneNumber = RandomPhoneNumber(),
                    Description = "Demo Administrator of the Site"
                },
                                   "Dmrss6HDRwd");
            }
            userId = userManager.FindByEmail("*****@*****.**").Id;
            userManager.AddToRole(userId, "Admin");


            if (!context.Users.Any(u => u.Email == "*****@*****.**"))
            {
                userManager.Create(new ApplicationUser()
                {
                    Email       = "*****@*****.**",
                    UserName    = "******",
                    FirstName   = "Submitter",
                    LastName    = "Demo",
                    AvatarPath  = "/Avatars/DemoUserAvatars/4.jpg",
                    PhoneNumber = RandomPhoneNumber(),
                    Description = "Demo Submitter of the Site"
                },
                                   "Dmrss6HDRwd");
            }
            userId = userManager.FindByEmail("*****@*****.**").Id;
            userManager.AddToRole(userId, "Submitter");


            if (!context.Users.Any(u => u.Email == "*****@*****.**"))
            {
                userManager.Create(new ApplicationUser()
                {
                    Email       = "*****@*****.**",
                    UserName    = "******",
                    FirstName   = "ProjectManager",
                    LastName    = "Demo",
                    AvatarPath  = "/Avatars/DemoUserAvatars/5.jpg",
                    PhoneNumber = RandomPhoneNumber(),
                    Description = "Demo ProjectManager of the Site"
                },
                                   "Dmrss6HDRwd");
            }
            userId = userManager.FindByEmail("*****@*****.**").Id;
            userManager.AddToRole(userId, "ProjectManager");


            if (!context.Users.Any(u => u.Email == "*****@*****.**"))
            {
                userManager.Create(new ApplicationUser()
                {
                    Email       = "*****@*****.**",
                    UserName    = "******",
                    FirstName   = "Developer",
                    LastName    = "Demo",
                    AvatarPath  = "/Avatars/DemoUserAvatars/6.jpg",
                    PhoneNumber = RandomPhoneNumber(),
                    Description = "Demo Developer of the Site"
                },
                                   "Dmrss6HDRwd");
            }
            userId = userManager.FindByEmail("*****@*****.**").Id;
            userManager.AddToRole(userId, "Developer");


            for (int i = 0; i < 10; i++)
            {
                var name      = generateRandomName();
                var emailCurr = $"{name.Item1}{name.Item2}@mailinator.com";
                if (!context.Users.Any(u => u.Email == emailCurr))
                {
                    userManager.Create(new ApplicationUser()
                    {
                        Email       = emailCurr,
                        UserName    = emailCurr,
                        FirstName   = $"{name.Item1}",
                        LastName    = $"{name.Item2}",
                        Description = "Developer",
                        AvatarPath  = "/Avatars/DemoUserAvatars/7.jpg",
                        PhoneNumber = RandomPhoneNumber()
                    },
                                       "123456Abc$");
                }
                userId = userManager.FindByEmail(emailCurr).Id;
                userManager.AddToRole(userId, "Developer");
            }

            for (int i = 0; i < 10; i++)
            {
                var name      = generateRandomName();
                var emailCurr = $"{name.Item1}{name.Item2}@mailinator.com";
                if (!context.Users.Any(u => u.Email == emailCurr))
                {
                    userManager.Create(new ApplicationUser()
                    {
                        Email       = emailCurr,
                        UserName    = emailCurr,
                        FirstName   = $"{name.Item1}",
                        LastName    = $"{name.Item2}",
                        Description = "ProjectManager",
                        AvatarPath  = "/Avatars/DemoUserAvatars/8.jpg",
                        PhoneNumber = RandomPhoneNumber()
                    },
                                       "123456Abc$");;
                }
                userId = userManager.FindByEmail(emailCurr).Id;
                userManager.AddToRole(userId, "ProjectManager");
            }

            for (int i = 0; i < 10; i++)
            {
                var name      = generateRandomName();
                var emailCurr = $"{name.Item1}{name.Item2}@mailinator.com";
                if (!context.Users.Any(u => u.Email == emailCurr))
                {
                    userManager.Create(new ApplicationUser()
                    {
                        Email       = emailCurr,
                        UserName    = emailCurr,
                        FirstName   = $"{name.Item1}",
                        Description = "Submitter",

                        LastName    = $"{name.Item2}",
                        AvatarPath  = "/Avatars/DemoUserAvatars/d1.jpg",
                        PhoneNumber = RandomPhoneNumber()
                    },
                                       "123456Abc$");
                }
                userId = userManager.FindByEmail(emailCurr).Id;
                userManager.AddToRole(userId, "Submitter");
            }
            #endregion
            context.SaveChanges();
            #region add connection sessions
            var user1 = userManager.Users.ToList().Where(u => u.Email == "*****@*****.**").FirstOrDefault();
            var user2 = userManager.Users.ToList().Where(u => u.Email == "*****@*****.**").FirstOrDefault();


            Connection seedConnection = new Connection();
            seedConnection.Users.Add(user1);
            seedConnection.Users.Add(user2);
            seedConnection.isArchived = false;
            seedConnection.Created    = DateTime.Now;
            context.Connections.Add(seedConnection);


            #endregion
            context.SaveChanges();
            #region add Messages to Chat
            foreach (var connection in user1.Connections)
            {
                for (int j = 0; j < 10; j++)
                {
                    Message message = new Message();
                    message.Created      = DateTime.Now;
                    message.ConnectionId = connection.Id;
                    if (j % 2 == 0)
                    {
                        message.SenderId = user1.Id;
                        message.Content  = $"{user1.FullName} this is test {j}";
                    }
                    else
                    {
                        message.SenderId = user2.Id;
                        message.Content  = $"{user2.FullName} this is test {j}";
                    }
                    context.Messages.Add(message);
                }
            }
            #endregion
            context.SaveChanges();

            #region add users to projects
            List <ApplicationUser> ProjectManagers = roleHelper.UsersInRole("ProjectManager").ToList();
            List <ApplicationUser> Developers      = roleHelper.UsersInRole("Developer").ToList();
            List <ApplicationUser> Submitters      = roleHelper.UsersInRole("Submitter").ToList();
            foreach (var project in context.Projects.ToList())
            {
                projectHelper.AddUserToProject(ProjectManagers[rand.Next(ProjectManagers.Count)].Id, project.Id);
                for (int i = 0; i < 3; i++)
                {
                    var randDev = rand.Next(Developers.Count);
                    var randSub = rand.Next(Submitters.Count);
                    projectHelper.AddUserToProject(Developers[randDev].Id, project.Id);
                    projectHelper.AddUserToProject(Submitters[randSub].Id, project.Id);
                }
            }
            #endregion
            context.SaveChanges();
            #region seed tickets 10 tickets/project
            List <string> supportIssues = new List <string>()
            {
                "The Login is not working for 3rd party", "Tickets do not Display text for zero notifications or histories",
                "Project names are not displayed right", "Need to add Users to projects", "add verification for file/image upload",
                "add a new Helper class for notifications", "Seed method duplicating notifications when update-database is ran", "Setup default Avatar images for users",
                "When uploading custom avatar image, it does not update database", "upload database to Azure", "test"
            };

            List <string> supportDiscription = new List <string>()
            {
                "The 3rd party login is not connecting to the correct service.", "Where there are zero notifications or histories for a ticket. It is displaying a empty data table"
                , "The project names are displaying the incorrect value.", "create a seed method to add users to projects. Also create a manage project to add users to the project", "File/image verification. so only certain files formats are uploaded. ",
                "Create a helper class that deals with all the methods for creating and displaying notifications for tickets, projects and users.", "when updateDatabase is ran, it is duplicating methods in the seed methods, causing issues with projects and tickets."
                , "There is no default Avatar image set up for the users. Add a feature in registry and manage user profile for uploading an avatar. if no avatar is uploaded add a default image", "the custom avatar image path is not being updated in the database.",
                "create a new database in Azure and upload the current working database to it.", "test"
            };
            List <TicketPriority> ticketPriorities = ticketHelper.ListTicketProities();
            List <TicketType>     ticketTypes      = ticketHelper.ListTicketTypes();
            var StatusId = context.TicketStatuses.Where(ts => ts.Name == "Open").FirstOrDefault().Id;
            foreach (var project in context.Projects.ToList())
            {
                List <ApplicationUser> projectDevelopers = projectHelper.ListUserOnProjectInRole(project.Id, "Developer").ToList();
                List <ApplicationUser> projectSubmitters = projectHelper.ListUserOnProjectInRole(project.Id, "Submitter").ToList();

                for (int i = 0; i < 10; i++)
                {
                    Ticket seedTicket = new Ticket();
                    var    randDev    = rand.Next(projectDevelopers.Count);
                    var    randSub    = rand.Next(projectSubmitters.Count);

                    seedTicket.DeveloperId = projectDevelopers[randDev].Id;
                    seedTicket.SubmitterId = projectSubmitters[randSub].Id;

                    seedTicket.TicketStatusId   = StatusId;
                    seedTicket.TicketPriorityId = ticketPriorities[rand.Next(ticketPriorities.Count)].Id;
                    seedTicket.TicketTypeId     = ticketTypes[rand.Next(ticketTypes.Count)].Id;
                    seedTicket.Created          = DateTime.Now;
                    seedTicket.Issue            = supportIssues[i];
                    seedTicket.IssueDescription = supportDiscription[i];
                    seedTicket.IsArchived       = false;
                    seedTicket.IsResolved       = false;
                    seedTicket.ProjectId        = project.Id;
                    context.Tickets.Add(seedTicket);
                }
            }
            #endregion
            context.SaveChanges();
            #region seed notifications and Histories
            #region project creation notification
            foreach (var project in context.Projects.ToList())
            {
                foreach (var user in project.Users)
                {
                    var newNotification = new ProjectNotification()
                    {
                        ProjectId        = project.Id,
                        UserId           = user.Id,
                        Created          = DateTime.Now,
                        Icon             = "fa-sitemap",
                        NotificationType = "success",
                        Subject          = $"Added to Project Id: {project.Id}",
                        Message          = $"Hello, {user.FullName} you have been Added to the project: {project.Name}",
                    };
                    context.Notifications.Add(newNotification);
                }
            }
            context.SaveChanges();
            #endregion
            #region project edit add users, remove users.
            foreach (var project in context.Projects.ToList())
            {
                List <ApplicationUser> UsersNotInProject = projectHelper.ListUsesNotOnProjectInExceptInRole(project.Id, "ProjectManager").ToList();
                List <ApplicationUser> oldUserList       = projectHelper.ListUserOnProjectExceptInRole(project.Id, "ProjectManager").ToList();

                var oldProject = context.Projects.AsNoTracking().FirstOrDefault(p => p.Id == project.Id);
                for (int i = 0; i < 5; i++)
                {
                    var userAddId = UsersNotInProject[rand.Next(UsersNotInProject.Count)].Id;
                    projectHelper.RemoveUserFromProject(oldUserList[rand.Next(oldUserList.Count)].Id, project.Id);
                    projectHelper.AddUserToProject(userAddId, project.Id);
                    context.SaveChanges();
                }

                project.DueDate     = DateTime.Now;
                project.Name        = $"{project.Name}v2";
                project.Description = $"{project.Description} Description has been changed to this";
                context.SaveChanges();
                var newProject = context.Projects.AsNoTracking().FirstOrDefault(p => p.Id == project.Id);
                seedHelper.ProjectHistoriesEdit(oldProject, newProject);
                seedHelper.ProjectChangedNotification(newProject, oldProject, oldUserList);
            }
            context.SaveChanges();
            #endregion

            #region seed ticket creation Notifications
            foreach (var ticket in context.Tickets)
            {
                seedHelper.NewTicketNotification(ticket);
            }
            #endregion

            #region seed ticket edit notifications and Histories
            var TicketPriorities = context.TicketPriorities.ToList();
            var TicketStatuses   = context.TicketStatuses.ToList();
            var TicketTypes      = context.TicketTypes.ToList();
            foreach (var ticket in context.Tickets.ToList().Take(10))
            {
                var oldTicket = context.Tickets.AsNoTracking().FirstOrDefault(t => t.Id == ticket.Id);

                List <ApplicationUser> projectDevelopers = projectHelper.ListUserOnProjectInRole(ticket.project.Id, "Developer").ToList();

                //ticket.TicketPriorityId;
                ticket.TicketPriorityId = TicketPriorities[rand.Next(TicketPriorities.Count)].Id;
                ticket.TicketStatusId   = TicketStatuses[rand.Next(TicketStatuses.Count)].Id;
                ticket.TicketTypeId     = TicketTypes[rand.Next(TicketTypes.Count)].Id;
                ticket.DeveloperId      = projectDevelopers[rand.Next(projectDevelopers.Count)].Id;
                context.SaveChanges();
                var newTicket = context.Tickets.AsNoTracking().FirstOrDefault(t => t.Id == ticket.Id);
                seedHelper.TicketHistoryEdit(oldTicket, newTicket);
                seedHelper.TicketChangeNotification(oldTicket, newTicket);
            }
            context.SaveChanges();
            #endregion
            #endregion
            #region seed ticket comments and attachments
            List <Project> projects = context.Projects.ToList();
            foreach (var project in projects)
            {
                List <ApplicationUser> UsersInProject = projectHelper.ListUsersOnProject(project.Id);
                var tickets = context.Tickets.Where(t => t.ProjectId == project.Id).ToList();

                TicketComment newTicket0Comment = new TicketComment()
                {
                    TicketId = tickets[0].Id,
                    UserId   = tickets[0].DeveloperId,
                    Comment  = "Checked the Code for the 3rd part ports and SMTP server. Looks correct. ",
                    Created  = DateTime.Now
                };
                context.TicketComments.Add(newTicket0Comment);
                //TicketAttachment newTicketAttachment0 = new TicketAttachment()
                //{
                //    TicketId = tickets[0].Id,
                //    UserId = tickets[0].DeveloperId,
                //    Created = DateTime.Now,
                //    FilePath =
                //};
                //context.TicketAttachments.Add(newTicketAttachment0);

                TicketComment newTicket0Comment2 = new TicketComment()
                {
                    TicketId = tickets[0].Id,
                    UserId   = tickets[0].DeveloperId,
                    Comment  = "Checked Account controller. The 3rd party login code was commented out. un-commented and it is working ",
                    Created  = DateTime.Now
                };
                context.TicketComments.Add(newTicket0Comment2);

                TicketComment newTicket1Comment1 = new TicketComment()
                {
                    TicketId = tickets[1].Id,
                    UserId   = tickets[1].DeveloperId,
                    Comment  = "looked at the Controller and the view for tickets. Created a If statement in the view",
                    Created  = DateTime.Now
                };
                context.TicketComments.Add(newTicket1Comment1);
                TicketAttachment newTicket1Attachment0 = new TicketAttachment()
                {
                    TicketId    = tickets[1].Id,
                    UserId      = tickets[1].DeveloperId,
                    Created     = DateTime.Now,
                    FilePath    = "/Uploads/ticketif.PNG",
                    FileName    = "ticketif.PNG",
                    Description = "ticketif.PNG"
                };
                context.TicketAttachments.Add(newTicket1Attachment0);
                TicketAttachment newTicket1Attachment1 = new TicketAttachment()
                {
                    TicketId    = tickets[1].Id,
                    UserId      = tickets[1].DeveloperId,
                    Created     = DateTime.Now,
                    FilePath    = "/Uploads/attachmentview.PNG",
                    FileName    = "attachmentview.PNG",
                    Description = "attachmentview.PNG"
                };
                context.TicketAttachments.Add(newTicket1Attachment1);

                TicketComment newTicket1Comment2 = new TicketComment()
                {
                    TicketId = tickets[1].Id,
                    UserId   = tickets[1].DeveloperId,
                    Comment  = "Found that I needed to make sure the list of notifications or histories where checked against null and length of Zero",
                    Created  = DateTime.Now
                };
                context.TicketComments.Add(newTicket1Comment2);
                TicketComment newTicket2Comment0 = new TicketComment()
                {
                    TicketId = tickets[2].Id,
                    UserId   = tickets[2].DeveloperId,
                    Comment  = "Checked the View, it was not referencing the project name, it was looking at a null object",
                    Created  = DateTime.Now
                };
                context.TicketComments.Add(newTicket2Comment0);
                TicketComment newTicket3Comment0 = new TicketComment()
                {
                    TicketId = tickets[3].Id,
                    UserId   = tickets[3].DeveloperId,
                    Comment  = "Created a Seed section for adding users to a project",
                    Created  = DateTime.Now
                };
                context.TicketComments.Add(newTicket3Comment0);
                TicketAttachment newTicket3Attachment1 = new TicketAttachment()
                {
                    TicketId    = tickets[1].Id,
                    UserId      = tickets[1].DeveloperId,
                    Created     = DateTime.Now,
                    FilePath    = "/Uploads/seetprojectuser.PNG",
                    FileName    = "seetprojectuser.PNG",
                    Description = "seetprojectuser.PNG"
                };
                context.TicketAttachments.Add(newTicket3Attachment1);
                TicketAttachment newTicket3Attachment2 = new TicketAttachment()
                {
                    TicketId    = tickets[1].Id,
                    UserId      = tickets[1].DeveloperId,
                    Created     = DateTime.Now,
                    FilePath    = "/Uploads/projectviewListBox.PNG",
                    FileName    = "projectviewListBox.PNG",
                    Description = "projectviewListBox.PNG"
                };
                context.TicketAttachments.Add(newTicket3Attachment2);
                TicketComment newTicket3Comment1 = new TicketComment()
                {
                    TicketId = tickets[3].Id,
                    UserId   = tickets[3].DeveloperId,
                    Comment  = "Created a multiselect List in the create and edit for projects users and users not in the project ",
                    Created  = DateTime.Now
                };
                context.TicketComments.Add(newTicket3Comment1);
                TicketComment newTicket3Comment2 = new TicketComment()
                {
                    TicketId = tickets[3].Id,
                    UserId   = tickets[3].DeveloperId,
                    Comment  = "Created a method in the post that looped through the selected users added to project ",
                    Created  = DateTime.Now
                };
                context.TicketComments.Add(newTicket3Comment2);
                TicketComment newTicket3Comment3 = new TicketComment()
                {
                    TicketId = tickets[3].Id,
                    UserId   = tickets[3].DeveloperId,
                    Comment  = "in the method, removed all the previous user then add the new list from the edit and create. It is working now ",
                    Created  = DateTime.Now
                };
                context.TicketComments.Add(newTicket3Comment3);
                TicketComment newTicket4Comment0 = new TicketComment()
                {
                    TicketId = tickets[4].Id,
                    UserId   = tickets[4].DeveloperId,
                    Comment  = "In the register and edit user viewModels added a Avatar HttpPostedFileBase property",
                    Created  = DateTime.Now
                };
                context.TicketComments.Add(newTicket4Comment0);
                TicketComment newTicket4Comment1 = new TicketComment()
                {
                    TicketId = tickets[4].Id,
                    UserId   = tickets[4].DeveloperId,
                    Comment  = "Created helper files FileUploadValidator, sluggerHelper, StringUtilites",
                    Created  = DateTime.Now
                };
                context.TicketComments.Add(newTicket4Comment1);
                TicketComment newTicket4Comment2 = new TicketComment()
                {
                    TicketId = tickets[4].Id,
                    UserId   = tickets[4].DeveloperId,
                    Comment  = "Added the method to verify the input file for the avatar and create a custom name. then added it to the User",
                    Created  = DateTime.Now
                };
                context.TicketComments.Add(newTicket4Comment2);
                context.SaveChanges();
            }
            #endregion
        }
        protected override void Seed(BugTracker_1._1.Models.ApplicationDbContext context)
        {
            var userManager     = new UserManager <ApplicationUser>(new UserStore <ApplicationUser>(context));
            var roleManager     = new RoleManager <IdentityRole>(new RoleStore <IdentityRole>(context));
            var userRolesHelper = new UserRolesHelper();
            var projectHelper   = new ProjectHelper();
            var random          = new Random();

            List <Ticket>          ticketList      = new List <Ticket>();
            List <ApplicationUser> projectManagers = new List <ApplicationUser>();
            List <ApplicationUser> developers      = new List <ApplicationUser>();
            List <ApplicationUser> submitters      = new List <ApplicationUser>();

            var adminList          = userRolesHelper.UsersInRole("Admin");
            var developerList      = userRolesHelper.UsersInRole("Developer");
            var submitterList      = userRolesHelper.UsersInRole("Submitter");
            var projectManagerList = userRolesHelper.UsersInRole("Project Manager");

            projectManagers.AddRange(userRolesHelper.UsersInRole("Project Manager"));
            developers.AddRange(userRolesHelper.UsersInRole("Developer"));
            submitters.AddRange(userRolesHelper.UsersInRole("Submitter"));


            if (!context.Roles.Any(r => r.Name == "Admin"))
            {
                roleManager.Create(new IdentityRole {
                    Name = "Admin"
                });
            }

            if (!context.Roles.Any(r => r.Name == "Project Manager"))
            {
                roleManager.Create(new IdentityRole {
                    Name = "Project Manager"
                });
            }

            if (!context.Roles.Any(r => r.Name == "Submitter"))
            {
                roleManager.Create(new IdentityRole {
                    Name = "Submitter"
                });
            }

            if (!context.Roles.Any(r => r.Name == "Developer"))
            {
                roleManager.Create(new IdentityRole {
                    Name = "Developer"
                });
            }

            var RichardKnottEmail      = WebConfigurationManager.AppSettings["RichardKnottEmail"];
            var RichardKnottPassword   = WebConfigurationManager.AppSettings["RichardKnottPassword"];
            var AmyAdamsEmail          = WebConfigurationManager.AppSettings["AmyAdamsEmail"];
            var AmyAdamsPassword       = WebConfigurationManager.AppSettings["AmyAdamsPassword"];
            var BenjaminBrattEmail     = WebConfigurationManager.AppSettings["BenjaminBrattEmail"];
            var BenjaminBrattPassword  = WebConfigurationManager.AppSettings["BenjaminBrattPassword"];
            var CourtneyCoxEmail       = WebConfigurationManager.AppSettings["CourtneyCoxEmail"];
            var CourtneyCoxPassword    = WebConfigurationManager.AppSettings["CourtneyCoxPassword"];
            var DavidDuchovnyEmail     = WebConfigurationManager.AppSettings["DavidDuchovnyEmail"];
            var DavidDuchovnyPassword  = WebConfigurationManager.AppSettings["DavidDuchovnyPassword"];
            var EmilioEstevezEmail     = WebConfigurationManager.AppSettings["EmilioEstevezEmail"];
            var EmilioEstevezPassword  = WebConfigurationManager.AppSettings["EmilioEstevezPassword"];
            var FreddieFenderEmail     = WebConfigurationManager.AppSettings["FreddieFenderEmail"];
            var FreddieFenderPassword  = WebConfigurationManager.AppSettings["FreddieFenderPassword"];
            var GaryGulmanEmail        = WebConfigurationManager.AppSettings["GaryGulmanEmail"];
            var GaryGulmanPassword     = WebConfigurationManager.AppSettings["GaryGulmanPassword"];
            var HarryHamlinEmail       = WebConfigurationManager.AppSettings["HarryHamlinEmail"];
            var HarryHamlinPassword    = WebConfigurationManager.AppSettings["HarryHamlinPassword"];
            var AlanAldaEmail          = WebConfigurationManager.AppSettings["AlanAldaEmail"];
            var AlanAldaPassword       = WebConfigurationManager.AppSettings["AlanAldaPassword"];
            var BenjaminButtonEmail    = WebConfigurationManager.AppSettings["BenjaminButtonEmail"];
            var BenjaminButtonPassword = WebConfigurationManager.AppSettings["BenjaminButtonPassword"];
            var ChevyChaseEmail        = WebConfigurationManager.AppSettings["ChevyChaseEmail"];
            var ChevyChasePassword     = WebConfigurationManager.AppSettings["ChevyChasePassword"];
            var DannyDeVitoEmail       = WebConfigurationManager.AppSettings["DannyDeVitoEmail"];
            var DannyDeVitoPassword    = WebConfigurationManager.AppSettings["DannyDeVitoPassword"];



            if (!context.Users.Any(u => u.Email == RichardKnottEmail))
            {
                userManager.Create(new ApplicationUser()
                {
                    Email     = RichardKnottEmail,
                    UserName  = RichardKnottEmail,
                    FirstName = "Richard",
                    LastName  = "Knott"
                }, RichardKnottPassword);


                var userId = userManager.FindByEmail(RichardKnottEmail).Id;
                userManager.AddToRole(userId, "Admin");
            }

            if (!context.Users.Any(u => u.Email == AmyAdamsEmail))
            {
                userManager.Create(new ApplicationUser()
                {
                    Email     = AmyAdamsEmail,
                    UserName  = AmyAdamsEmail,
                    FirstName = "Amy",
                    LastName  = "Adams"
                }, AmyAdamsPassword);


                var userId = userManager.FindByEmail(AmyAdamsEmail).Id;
                userManager.AddToRole(userId, "Admin");
            }

            if (!context.Users.Any(u => u.Email == (BenjaminBrattEmail)))
            {
                userManager.Create(new ApplicationUser()
                {
                    Email     = BenjaminBrattEmail,
                    UserName  = BenjaminBrattEmail,
                    FirstName = "Benjamin",
                    LastName  = "Bratt"
                }, BenjaminBrattPassword);


                var userId = userManager.FindByEmail(BenjaminBrattEmail).Id;
                userManager.AddToRole(userId, "Project Manager");
            }

            if (!context.Users.Any(u => u.Email == CourtneyCoxEmail))
            {
                userManager.Create(new ApplicationUser()
                {
                    Email     = CourtneyCoxEmail,
                    UserName  = CourtneyCoxEmail,
                    FirstName = "Courtney",
                    LastName  = "Cox"
                }, CourtneyCoxPassword);


                var userId = userManager.FindByEmail(CourtneyCoxEmail).Id;
                userManager.AddToRole(userId, "Project Manager");
            }

            if (!context.Users.Any(u => u.Email == DavidDuchovnyEmail))
            {
                userManager.Create(new ApplicationUser()
                {
                    Email     = DavidDuchovnyEmail,
                    UserName  = DavidDuchovnyEmail,
                    FirstName = "David",
                    LastName  = "Duchovny"
                }, DavidDuchovnyPassword);


                var userId = userManager.FindByEmail(DavidDuchovnyEmail).Id;
                userManager.AddToRole(userId, "Developer");
            }

            if (!context.Users.Any(u => u.Email == EmilioEstevezEmail))
            {
                userManager.Create(new ApplicationUser()
                {
                    Email     = EmilioEstevezEmail,
                    UserName  = EmilioEstevezEmail,
                    FirstName = "Emilio",
                    LastName  = "Estevez"
                }, EmilioEstevezPassword);


                var userId = userManager.FindByEmail(EmilioEstevezEmail).Id;
                userManager.AddToRole(userId, "Developer");
            }

            if (!context.Users.Any(u => u.Email == FreddieFenderEmail))
            {
                userManager.Create(new ApplicationUser()
                {
                    Email     = FreddieFenderEmail,
                    UserName  = FreddieFenderEmail,
                    FirstName = "Freddie",
                    LastName  = "Fender"
                }, FreddieFenderPassword);

                var userId = userManager.FindByEmail(FreddieFenderEmail).Id;
                userManager.AddToRole(userId, "Submitter");
            }

            if (!context.Users.Any(u => u.Email == GaryGulmanEmail))
            {
                userManager.Create(new ApplicationUser()
                {
                    Email     = GaryGulmanEmail,
                    UserName  = GaryGulmanEmail,
                    FirstName = "Gary",
                    LastName  = "Gulman"
                }, GaryGulmanPassword);


                var userId = userManager.FindByEmail(GaryGulmanEmail).Id;
                userManager.AddToRole(userId, "Submitter");
            }

            if (!context.Users.Any(u => u.Email == HarryHamlinEmail))
            {
                userManager.Create(new ApplicationUser()
                {
                    Email     = HarryHamlinEmail,
                    UserName  = HarryHamlinEmail,
                    FirstName = "Harry",
                    LastName  = "Hamlin"
                }, HarryHamlinPassword);


                var userId = userManager.FindByEmail(HarryHamlinEmail).Id;
                userManager.AddToRole(userId, "Submitter");
            }


            //For Demo Version
            if (!context.Users.Any(u => u.Email == AlanAldaEmail))
            {
                userManager.Create(new ApplicationUser()
                {
                    Email     = AlanAldaEmail,
                    UserName  = AlanAldaEmail,
                    FirstName = "Alan",
                    LastName  = "Alda"
                }, AlanAldaPassword);
                var userId = userManager.FindByEmail(AlanAldaEmail).Id;
                userManager.AddToRole(userId, "Admin");
            }

            if (!context.Users.Any(u => u.Email == BenjaminButtonEmail))
            {
                userManager.Create(new ApplicationUser()
                {
                    Email     = BenjaminButtonEmail,
                    UserName  = BenjaminButtonEmail,
                    FirstName = "Benjamin",
                    LastName  = "Button"
                }, BenjaminButtonPassword);
                var userId = userManager.FindByEmail(BenjaminButtonEmail).Id;
                userManager.AddToRole(userId, "Project Manager");
            }

            if (!context.Users.Any(u => u.Email == ChevyChaseEmail))
            {
                userManager.Create(new ApplicationUser()
                {
                    Email     = ChevyChaseEmail,
                    UserName  = ChevyChaseEmail,
                    FirstName = "Chevy",
                    LastName  = "Chase"
                }, ChevyChasePassword);
                var userId = userManager.FindByEmail(ChevyChaseEmail).Id;
                userManager.AddToRole(userId, "Developer");
            }

            if (!context.Users.Any(u => u.Email == DannyDeVitoEmail))
            {
                userManager.Create(new ApplicationUser()
                {
                    Email     = DannyDeVitoEmail,
                    UserName  = DannyDeVitoEmail,
                    FirstName = "Danny",
                    LastName  = "DeVito"
                }, DannyDeVitoPassword);
                var userId = userManager.FindByEmail(DannyDeVitoEmail).Id;
                userManager.AddToRole(userId, "Submitter");
            }


            context.SaveChanges();

            //Ticket Type Seed
            context.TicketTypes.AddOrUpdate(
                tt => tt.Name,
                new TicketType()
            {
                Name = "Software"
            },
                new TicketType()
            {
                Name = "Hardware"
            },
                new TicketType()
            {
                Name = "UI"
            },
                new TicketType()
            {
                Name = "Defect"
            },
                new TicketType()
            {
                Name = "Other"
            }
                );

            //Ticket Priority Seed
            context.TicketPriorities.AddOrUpdate(
                tp => tp.Name,
                new TicketPriority()
            {
                Name = "Low"
            },
                new TicketPriority()
            {
                Name = "Medium"
            },
                new TicketPriority()
            {
                Name = "High"
            },
                new TicketPriority()
            {
                Name = "On Hold"
            }
                );

            //Ticket Status Seed
            context.TicketStatuses.AddOrUpdate(
                ts => ts.Name,
                new TicketStatus()
            {
                Name = "Open"
            },
                new TicketStatus()
            {
                Name = "Assigned"
            },
                new TicketStatus()
            {
                Name = "Resolved"
            },
                new TicketStatus()
            {
                Name = "Reopened"
            },
                new TicketStatus()
            {
                Name = "Archived"
            }
                );

            //Project Seed
            context.Projects.AddOrUpdate(
                p => p.Name,
                new Project()
            {
                Name = "Veteran's Park Community Event Registration Software", Created = DateTime.Now.AddDays(-60), IsArchived = true, Description = "Orange County needs a professional and robust new events scheduling and registration software program."
            },
                new Project()
            {
                Name = "Circus Vargas Employee Leave Tracker", Created = DateTime.Now.AddDays(-45), Description = "Circus Vargas contacted us to create an employee leave tracking program for FMLA, PDL, CFRA leave."
            },
                new Project()
            {
                Name = "City of Lights New Hire On-Boarding Software", Created = DateTime.Now.AddDays(-30), Description = "City of Lights Human Resources Department needs a new HR program for their newly hired employees."
            },
                new Project()
            {
                Name = "Schools First Credit Union Financial Software", Created = DateTime.Now.AddDays(-15), Description = "Schools First is looking to purchase our Financial Portal software, but is asking us to customize."
            },
                new Project()
            {
                Name = "UrTurn Bidding Software", Created = DateTime.Now.AddDays(-7), Description = "UrTurn start-up wants us to make a bidding software program."
            },
                new Project()
            {
                Name = "Doublz Deli Register Software", Created = DateTime.Now.AddDays(-45), Description = "Doublz Deli purchased our Restaurant Cashier software."
            },
                new Project()
            {
                Name = "True Movies Streaming Service", Created = DateTime.Now.AddDays(-5), Description = "True Movies contracted with us to create an updatd online streaming portal."
            },
                new Project()
            {
                Name = "Pets Bin Dog Grooming Client Software", Created = DateTime.Now.AddDays(-15), Description = "Pets Bin purchased our new floor-to-ceiling client software."
            },
                new Project()
            {
                Name = "Syndicate Attorneys, LLP", Created = DateTime.Now, Description = "Syndicate Attorneys contracted with us to create a Client-Conflict program to avoid representing opposing parties."
            },
                new Project()
            {
                Name = "Tricycle Club Casino", Created = DateTime.Now.AddDays(-2), Description = "The Tricycle Club purchased our Human Resources On-Boarding software."
            }

                );
            context.SaveChanges();

            // Assign users to projects by Role
            //foreach (var project in context.Projects.ToList())
            //{
            //    foreach (var user in userRolesHelper.UsersInRole("Admin"))
            //    {
            //        projectHelper.AddUserToProject(user.Id, project.Id);
            //    }
            //    projectHelper.AddUserToProject(projectManagers[random.Next(projectManagers.Count -1)].Id, project.Id);

            //    // Assign Developers
            //    var firstDeveloper = developers[random.Next(developers.Count)].Id;
            //    var secondDeveloper = developers[random.Next(developers.Count)].Id;
            //    while (firstDeveloper == secondDeveloper)
            //    {
            //        secondDeveloper = developers[random.Next(developers.Count)].Id;
            //    }
            //    projectHelper.AddUserToProject(firstDeveloper, project.Id);
            //    projectHelper.AddUserToProject(secondDeveloper, project.Id);

            //    //Assign Submitters
            //    var firstSubmitter = submitters[random.Next(submitters.Count)].Id;
            //    var secondSubmitter = submitters[random.Next(submitters.Count)].Id;
            //    while (firstSubmitter == secondSubmitter)
            //    {
            //        secondSubmitter = submitters[random.Next(submitters.Count)].Id;
            //    }
            //    projectHelper.AddUserToProject(firstSubmitter, project.Id);
            //    projectHelper.AddUserToProject(secondSubmitter, project.Id);
            //}

            // Creation of assignments to projects and tickets

            //foreach (var project in context.Projects.ToList())
            //{
            //    projectManagers = projectHelper.ListUsersOnProjectInRole(project.Id, "ProjectManager");
            //    developers = projectHelper.ListUsersOnProjectInRole(project.Id, "Developer");
            //    submitters = projectHelper.ListUsersOnProjectInRole(project.Id, "Submitter");

            //    foreach (var type in context.TicketTypes.ToList())
            //    {
            //        foreach (var status in context.TicketStatuses.ToList())
            //        {
            //            foreach (var priority in context.TicketPriorities.ToList())
            //            {

            //                var developerId = developers[random.Next(developers.Count)].Id;
            //                if (status.Name == "Open")
            //                {
            //                    developerId = null;
            //                }
            //                var resolved = false;
            //                var archived = false;
            //                if (status.Name == "Resolved")
            //                {
            //                    resolved = true;
            //                }
            //                if (status.Name == "Archived" || project.IsArchived == true)
            //                {
            //                    archived = true;
            //                }
            //                var newTicket = new Ticket()
            //                {
            //                    ProjectId = project.Id,
            //                    TicketPriorityId = priority.Id,
            //                    TicketTypeId = type.Id,
            //                    TicketStatusId = status.Id,
            //                    SubmitterId = submitters[random.Next(submitters.Count)].Id,
            //                    DeveloperId = developerId,
            //                    Created = DateTime.Now,
            //                    Issue = $"Ticket type:{type.Name}. Status:{status.Name}. Priority:{priority.Name}",
            //                    IssueDescription = $"This is a {type.Name} type of ticket for Project:{project.Name}.",
            //                    IsResolved = resolved,
            //                    IsArchived = archived
            //                };
            //                ticketList.Add(newTicket);
            //            }
            //        }
            //    }
            //}

            //context.Tickets.AddRange(ticketList);
            //context.SaveChanges();
            // end of creation of assignment of projects to projects and tickets

            var userList    = context.Users.ToList();
            var projectList = context.Projects.ToList();

            foreach (var project in projectList)
            {
                foreach (var user in userList)
                {
                    projectHelper.AddUserToProject(user.Id, project.Id);
                }
            }
        }