Пример #1
0
 public int InsertUserDetails(MODEL.User user)
 {
     using (dbContext)
     {
         dbContext.Users.Add(new DAC.User()
         {
             Last_Name   = user.LastName,
             First_Name  = user.FirstName,
             Employee_ID = user.EmployeeId
         });
         return(dbContext.SaveChanges());
     }
 }
Пример #2
0
        public int InsertTaskDetails(Task task)
        {
            using (dbContext)
            {
                if (task.Priority == 0)
                {
                    dbContext.ParentTasks.Add(new DAC.ParentTask()
                    {
                        Parent_Task_Name = task.Task_Name
                    });
                }
                else
                {
                    DAC.Task taskDetail = new DAC.Task()
                    {
                        Task_Name  = task.Task_Name,
                        Project_ID = task.Project_ID,
                        Start_Date = task.Start_Date,
                        End_Date   = task.End_Date,
                        Parent_ID  = task.Parent_ID,
                        Priority   = task.Priority,
                        Status     = task.Status
                    };
                    dbContext.Tasks.Add(taskDetail);
                    dbContext.SaveChanges();

                    var editDetails = (from editUser in dbContext.Users
                                       where editUser.User_ID.ToString().Contains(task.User.UserId.ToString())
                                       select editUser).ToList();
                    // Modify existing records
                    if (editDetails != null && editDetails.Count > 0)
                    {
                        editDetails.First().Task_ID = taskDetail.Task_ID;
                    }
                }
                return(dbContext.SaveChanges());
            }
        }
Пример #3
0
 public int InsertProjectDetails(MODEL.Project project)
 {
     using (dbContext)
     {
         DAC.Project proj = new DAC.Project()
         {
             Project_Name = project.ProjectName,
             Start_Date   = project.ProjectStartDate,
             End_Date     = project.ProjectEndDate,
             Priority     = project.Priority
         };
         dbContext.Projects.Add(proj);
         dbContext.SaveChanges();
         var editDetails = (from record in dbContext.Users
                            where record.User_ID.ToString().Contains(project.User.UserId.ToString())
                            select record).First();
         if (editDetails != null)
         {
             editDetails.Project_ID = proj.Project_ID;
         }
         return(dbContext.SaveChanges());
     }
 }
Пример #4
0
        public int InsertTaskDetails(Task task)
        {
            using (dbContext)
            {
                DAC.Task dbTask = null;
                if (task.IsParentTask)
                {
                    dbTask = new DAC.Task
                    {
                        Task_Name  = task.Name,
                        Project_ID = task.Project.Id
                    };
                }
                else
                {
                    dbTask = new DAC.Task
                    {
                        Task_Name  = task.Name,
                        Project_ID = task.Project != null ? task.Project.Id : (int?)null,
                        Start_Date = task.StartDate,
                        End_Date   = task.EndDate,
                        Parent_ID  = task.ParentTask != null ? task.ParentTask.Id : (int?)null,
                        Priority   = task.Priority
                    };
                }
                dbContext.Tasks.Add(dbTask);
                dbContext.SaveChanges();
                //if (task.Priority == 0)
                //{
                //    dbContext.ParentTasks.Add(new DAC.ParentTask()
                //    {
                //        Parent_Task_Name = task.Name

                //    });
                //}
                //else
                //{
                //    DAC.Task taskDetail = new DAC.Task()
                //    {
                //        Task_Name = task.Name,
                //        Project_ID = task.Project.Id,
                //        Start_Date = task.StartDate,
                //        End_Date = task.EndDate,
                //        Parent_ID = task.ParentTask.Id,
                //        Priority = task.Priority,
                //        Status = task.Status
                //    };
                //    dbContext.Tasks.Add(taskDetail);
                //    dbContext.SaveChanges();

                //    var editDetails = (from editUser in dbContext.Users
                //                       where editUser.User_ID.ToString().Contains(task.User.Id.ToString())
                //                       select editUser).ToList();
                //    // Modify existing records
                //    if (editDetails != null && editDetails.Count>0)
                //    {
                //        editDetails.First().Task_ID = taskDetail.Task_ID;
                //    }
                //}
                return(dbContext.SaveChanges());
            }
        }