Ejemplo n.º 1
0
        // Update Tasks
        public void UpdateTask(Task editTask)
        {
            ProjectManagerContext pmContext = new ProjectManagerContext();
            var existingTask = pmContext.Tasks.Where(m => m.Task_ID == editTask.Task_ID).FirstOrDefault();

            existingTask.Parent_ID  = editTask.Parent_ID;
            existingTask.TaskName   = editTask.TaskName;
            existingTask.Start_Date = editTask.Start_Date;
            existingTask.End_Date   = editTask.End_Date;
            existingTask.Priority   = editTask.Priority;

            pmContext.SaveChanges();

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

            var existingUser = pmContext.Users.Where(m => m.Task_ID == editTask.Task_ID).FirstOrDefault();

            if (newUser != null)
            {
                existingUser.Employee_ID = newUser.Employee_ID;
                existingUser.FirstName   = newUser.FirstName;
                existingUser.LastName    = newUser.LastName;
                pmContext.SaveChanges();
            }
        }
Ejemplo n.º 2
0
        //Add New Users
        public void AddUser(User newUser)
        {
            ProjectManagerContext pmContext = new ProjectManagerContext();

            pmContext.Users.Add(newUser);
            pmContext.SaveChanges();
        }
Ejemplo n.º 3
0
        //Get Completed Tasks by Project Id
        public List <Task> GetCompletedTasksByProjectId(int projectId)
        {
            ProjectManagerContext pmContext = new ProjectManagerContext();
            var tasks = pmContext.Tasks.Where(m => m.Project_ID == projectId && m.End_Date > DateTime.Now);

            return(tasks.ToList());
        }
Ejemplo n.º 4
0
        //Delete User
        public void DeleteUser(int id)
        {
            ProjectManagerContext pmContext = new ProjectManagerContext();
            var deleteUser = pmContext.Users.Where(m => m.User_ID == id).FirstOrDefault();

            pmContext.Users.Remove(deleteUser);
            pmContext.SaveChanges();
        }
Ejemplo n.º 5
0
        // Get List of All Users
        public List <User> GetAllUsers()
        {
            ProjectManagerContext pmContext = new ProjectManagerContext();
            List <User>           UserList  = new List <User>();

            UserList = pmContext.Users.Distinct().ToList();
            UserList = UserList.GroupBy(i => i.Employee_ID).Select(g => g.First()).ToList();
            return(UserList);
        }
Ejemplo n.º 6
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();
        }
Ejemplo n.º 7
0
        // delete Tasks Method
        public void DeleteTask(int id)
        {
            ProjectManagerContext pmContext = new ProjectManagerContext();
            var existingUser = pmContext.Users.Where(m => m.Task_ID == id).FirstOrDefault();

            if (existingUser != null)
            {
                existingUser.Task_ID = null;
                pmContext.SaveChanges();
            }
            var deleteTask = pmContext.Tasks.Where(m => m.Task_ID == id).FirstOrDefault();

            pmContext.Tasks.Remove(deleteTask);
            pmContext.SaveChanges();
        }
Ejemplo n.º 8
0
        // Add New Project
        public void AddProject(Project newProject)
        {
            ProjectManagerContext pmContext = new ProjectManagerContext();

            pmContext.Projects.Add(newProject);
            pmContext.SaveChanges();

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

            User newUser = new User();

            newUser.User_ID     = 0;
            newUser.FirstName   = existingUser.FirstName;
            newUser.LastName    = existingUser.LastName;
            newUser.Project_ID  = newProject.Project_ID;
            newUser.Employee_ID = existingUser.Employee_ID;
            pmContext.Users.Add(newUser);
            pmContext.SaveChanges();
        }
Ejemplo n.º 9
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();
        }
Ejemplo n.º 10
0
        //Get List of All Parent Tasks
        public List <ParentTask> GetAllParentTasks()
        {
            ProjectManagerContext pmContext = new ProjectManagerContext();

            return(pmContext.ParentTasks.ToList());
        }
Ejemplo n.º 11
0
        //Get List of all projects
        #region Projects
        public List <Project> GetAllProjects()
        {
            ProjectManagerContext pmContext = new ProjectManagerContext();

            return(pmContext.Projects.ToList());
        }