예제 #1
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();
        }
예제 #2
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();
        }
예제 #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();
        }
예제 #4
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();
        }
예제 #5
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();
        }
예제 #6
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();
        }