Пример #1
0
        // Add Tasks
        public void AddTask(Task newTask)
        {
            ProjectManagerContext pmContext = new ProjectManagerContext();

            pmContext.Tasks.Add(newTask);
            pmContext.SaveChanges();

            var existingUser = pmContext.Users.Where(m => m.User_ID == newTask.User_ID).FirstOrDefault();

            User newUser = new User();

            newUser.User_ID     = 0;
            newUser.FirstName   = existingUser.FirstName;
            newUser.LastName    = existingUser.LastName;
            newUser.Project_ID  = newTask.Project_ID;
            newUser.Employee_ID = existingUser.Employee_ID;
            newUser.Task_ID     = newTask.Task_ID;
            pmContext.Users.Add(newUser);
            pmContext.SaveChanges();
        }
Пример #2
0
        // Update Existing User
        public void UpdateUser(User editUser)
        {
            ProjectManagerContext pmContext = new ProjectManagerContext();
            var existingUser = pmContext.Users.Where(m => m.User_ID == editUser.User_ID).FirstOrDefault();

            existingUser.Project_ID  = editUser.Project_ID;
            existingUser.FirstName   = editUser.FirstName;
            existingUser.LastName    = editUser.LastName;
            existingUser.Employee_ID = editUser.Employee_ID;

            pmContext.SaveChanges();
        }
Пример #3
0
        // Update Existing Project
        public void UpdateProject(Project editProject)

        {
            ProjectManagerContext pmContext = new ProjectManagerContext();
            var existingProject             = pmContext.Projects.Where(m => m.Project_ID == editProject.Project_ID).FirstOrDefault();

            existingProject.Project_ID  = editProject.Project_ID;
            existingProject.ProjectName = editProject.ProjectName;
            existingProject.StartDate   = editProject.StartDate;
            existingProject.EndDate     = editProject.EndDate;
            existingProject.Priority    = editProject.Priority;

            pmContext.SaveChanges();

            var newUser = pmContext.Users.Where(m => m.User_ID == editProject.User_ID).FirstOrDefault();

            var existingUser = pmContext.Users.Where(m => m.Project_ID == editProject.Project_ID && m.Task_ID == null).FirstOrDefault();

            existingUser.Employee_ID = newUser.Employee_ID;
            existingUser.FirstName   = newUser.FirstName;
            existingUser.LastName    = newUser.LastName;
            pmContext.SaveChanges();
        }