public HttpResponseMessage AddTask(Task task)
 {
     if (task == null)
     {
         return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Task cannot be null"));
     }
     try
     {
         var dbTask = new DAC.Task();
         dbTask = new DAC.Task
         {
             AssignedToUserId = task.AssignedToUserId,
             Name             = task.Name,
             StartDate        = task.StartDate,
             EndDate          = task.EndDate,
             Priority         = task.Priority,
             ProjectId        = task.ProjectId,
             ParentTaskId     = task.ParentTaskId
         };
         DbContext.Tasks.Add(dbTask);
         return(Request.CreateResponse(dbContext.SaveChanges()));
     }
     catch (Exception ex)
     {
         return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "Error in adding Task: " + ex.Message));
     }
 }
예제 #2
0
        public override int InsertTaskDetails(Models.Task task)
        {
            if (task.Priority == 0)
            {
                _mockBd.ParentTasks.Add(new DAC.ParentTask()
                {
                    Parent_Task = task.Task_Name
                });
            }
            else
            {
                DAC.Task taskDetail = new DAC.Task()
                {
                    Task1      = 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
                };
                _mockBd.Tasks.Add(taskDetail);

                var editDetails = (from editUser in _mockBd.Users
                                   where editUser.User_ID.ToString().Contains(task.User.UserId.ToString())
                                   select editUser).First();
                // Modify existing records
                if (editDetails != null)
                {
                    editDetails.Task_ID = taskDetail.Task_ID;
                }
            }
            return(1);
        }
예제 #3
0
        public virtual int InsertTaskDetails(Task task)
        {
            using (dbContext)
            {
                if (task.Priority == 0)
                {
                    dbContext.ParentTasks.Add(new DAC.ParentTask()
                    {
                        Parent_Task = task.Task_Name
                    });
                }
                else
                {
                    DAC.Task taskDetail = new DAC.Task()
                    {
                        Task1      = 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).First();
                    // Modify existing records
                    if (editDetails != null)
                    {
                        editDetails.Task_ID = taskDetail.Task_ID;
                    }
                }
                return(dbContext.SaveChanges());
            }
        }