Ejemplo n.º 1
0
        public void DeleteTask(int id)
        {
            ProjectTasksDBEntities taskDBEntities = new ProjectTasksDBEntities();
            TaskDetail             task           = taskDBEntities.TaskDetails.SingleOrDefault(p => p.TaskID == id);
            var entry = taskDBEntities.Entry(task);

            if (entry.State == System.Data.Entity.EntityState.Detached)
            {
                taskDBEntities.TaskDetails.Attach(task);
            }
            taskDBEntities.TaskDetails.Remove(task);
            taskDBEntities.SaveChanges();
        }
Ejemplo n.º 2
0
        public void DeleteProject(int id)
        {
            ProjectTasksDBEntities projectDBEntities = new ProjectTasksDBEntities();
            Project project = projectDBEntities.Projects.SingleOrDefault(p => p.ProjectID == id);
            var     entry   = projectDBEntities.Entry(project);

            if (entry.State == System.Data.Entity.EntityState.Detached)
            {
                projectDBEntities.Projects.Attach(project);
            }
            projectDBEntities.Projects.Remove(project);
            projectDBEntities.SaveChanges();
        }
Ejemplo n.º 3
0
        public void DeleteUser(int id)
        {
            ProjectTasksDBEntities taskDBEntities = new ProjectTasksDBEntities();
            User user  = taskDBEntities.Users.SingleOrDefault(p => p.UserID == id);
            var  entry = taskDBEntities.Entry(user);

            if (entry.State == System.Data.Entity.EntityState.Detached)
            {
                taskDBEntities.Users.Attach(user);
            }
            taskDBEntities.Users.Remove(user);
            taskDBEntities.SaveChanges();
        }
Ejemplo n.º 4
0
        public void AddProject(ProjectViewModel projectVM)
        {
            ProjectTasksDBEntities projectDBEntities = new ProjectTasksDBEntities();
            Project project = new Project();

            project.ProjectName = projectVM.ProjectName;
            project.StartDate   = Convert.ToDateTime(projectVM.StartDate);
            project.EndDate     = Convert.ToDateTime(projectVM.EndDate);
            project.Priority    = projectVM.Priority;
            project.Status      = (projectVM.Status == null) ? "" : projectVM.Status;

            projectDBEntities.Projects.Add(project);
            projectDBEntities.SaveChanges();
        }
Ejemplo n.º 5
0
        public void EditProject(ProjectViewModel projectVM)
        {
            ProjectTasksDBEntities projectDBEntities = new ProjectTasksDBEntities();
            Project project = projectDBEntities.Projects.SingleOrDefault(p => p.ProjectID == projectVM.ProjectID);

            project.ProjectName = projectVM.ProjectName;
            project.StartDate   = Convert.ToDateTime(projectVM.StartDate);
            project.EndDate     = Convert.ToDateTime(projectVM.EndDate);
            project.Priority    = projectVM.Priority;
            project.Status      = (projectVM.Status == null) ? "" : projectVM.Status;

            projectDBEntities.Projects.Attach(project);
            projectDBEntities.Entry(project).State = System.Data.Entity.EntityState.Modified;
            projectDBEntities.SaveChanges();
        }
Ejemplo n.º 6
0
        public void EditUser(UserViewModel userVM)
        {
            ProjectTasksDBEntities taskDBEntities = new ProjectTasksDBEntities();
            User user = taskDBEntities.Users.SingleOrDefault(p => p.UserID == userVM.UserID);

            user.FirstName  = userVM.FirstName;
            user.LastName   = userVM.LastName;
            user.EmployeeID = userVM.EmployeeID;
            if (userVM.TaskName != null && userVM.TaskName != "")
            {
                user.TaskID = taskDBEntities.TaskDetails.SingleOrDefault(t => t.TaskName == userVM.TaskName).TaskID;
            }
            if (userVM.ProjectName != null && userVM.ProjectName != "")
            {
                user.ProjectID = taskDBEntities.Projects.SingleOrDefault(p => p.ProjectName == userVM.ProjectName).ProjectID;
            }

            taskDBEntities.Users.Attach(user);
            taskDBEntities.Entry(user).State = System.Data.Entity.EntityState.Modified;
            taskDBEntities.SaveChanges();
        }
Ejemplo n.º 7
0
        public void AddTask(TaskViewModel taskVM)
        {
            ProjectTasksDBEntities taskDBEntities = new ProjectTasksDBEntities();
            TaskDetail             task           = new TaskDetail();

            task.TaskName = taskVM.TaskName;
            if (taskVM.ParentTaskName != null && taskVM.ParentTaskName != "")
            {
                task.ParentTaskID = taskDBEntities.TaskDetails.SingleOrDefault(p => p.TaskName == taskVM.ParentTaskName).TaskID;
            }

            if (taskVM.ProjectName != null && taskVM.ProjectName != "")
            {
                task.ProjectID = taskDBEntities.Projects.SingleOrDefault(p => p.ProjectName == taskVM.ProjectName).ProjectID;
            }
            task.StartDate = Convert.ToDateTime(taskVM.StartDate);
            task.EndDate   = Convert.ToDateTime(taskVM.EndDate);
            task.Priority  = taskVM.Priority;
            task.Status    = taskVM.Status;
            taskDBEntities.TaskDetails.Add(task);
            taskDBEntities.SaveChanges();
        }
Ejemplo n.º 8
0
        public void AddUser(UserViewModel userVM)
        {
            ProjectTasksDBEntities taskDBEntities = new ProjectTasksDBEntities();
            User user = new User();

            user.FirstName  = userVM.FirstName;
            user.LastName   = userVM.LastName;
            user.EmployeeID = userVM.EmployeeID;


            if (userVM.TaskName != null && userVM.TaskName != "")
            {
                user.TaskID = taskDBEntities.TaskDetails.SingleOrDefault(t => t.TaskName == userVM.TaskName).TaskID;
            }
            if (userVM.ProjectName != null && userVM.ProjectName != "")
            {
                user.ProjectID = taskDBEntities.Projects.SingleOrDefault(p => p.ProjectName == userVM.ProjectName).ProjectID;
            }

            taskDBEntities.Users.Add(user);
            taskDBEntities.SaveChanges();
        }
Ejemplo n.º 9
0
        public void EditTask(TaskViewModel taskVM)
        {
            ProjectTasksDBEntities taskDBEntities = new ProjectTasksDBEntities();
            TaskDetail             task           = taskDBEntities.TaskDetails.SingleOrDefault(p => p.TaskID == taskVM.TaskID);

            if (taskVM.ParentTaskName != null && taskVM.ParentTaskName != "")
            {
                task.ParentTaskID = taskDBEntities.TaskDetails.SingleOrDefault(p => p.TaskName == taskVM.ParentTaskName).TaskID;
            }

            if (taskVM.ProjectName != null && taskVM.ProjectName != "")
            {
                task.ProjectID = taskDBEntities.Projects.SingleOrDefault(p => p.ProjectName == taskVM.ProjectName).ProjectID;
            }

            task.StartDate = Convert.ToDateTime(taskVM.StartDate);
            task.EndDate   = Convert.ToDateTime(taskVM.EndDate);
            task.Priority  = taskVM.Priority;

            taskDBEntities.TaskDetails.Attach(task);
            taskDBEntities.Entry(task).State = System.Data.Entity.EntityState.Modified;
            taskDBEntities.SaveChanges();
        }