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

                    var editDetails = (from editUser in _projectManagerCtx.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(_projectManagerCtx.SaveChanges());
            }
        }
示例#3
0
 public int InsertProjectDetails(MODEL.Project project)
 {
     using (_projectManagerCtx)
     {
         DAC.Project proj = new DAC.Project()
         {
             Project_Name = project.ProjectName,
             Start_Date   = project.ProjectStartDate,
             End_Date     = project.ProjectEndDate,
             Priority     = project.Priority
         };
         _projectManagerCtx.Projects.Add(proj);
         _projectManagerCtx.SaveChanges();
         var editDetails = (from editUser in _projectManagerCtx.Users
                            where editUser.User_ID.ToString().Contains(project.User.UserId.ToString())
                            select editUser).First();
         // Modify existing records
         if (editDetails != null)
         {
             editDetails.Project_ID = proj.Project_ID;
         }
         return(_projectManagerCtx.SaveChanges());
     }
 }