Ejemplo n.º 1
0
        public bool UpdateTask(Task_Master task, ParentTask_Master parentTask)
        {
            try
            {
                Task_Master existTask = dbContext.Task_Master.Find(task.Task_ID);
                ((IObjectContextAdapter)dbContext).ObjectContext.Detach(existTask);

                dbContext.Entry(task).State = EntityState.Modified;
                dbContext.SaveChanges();

                ParentTask_Master existPTask = dbContext.ParentTask_Master.Find(parentTask.Parent_ID);
                ((IObjectContextAdapter)dbContext).ObjectContext.Detach(existPTask);

                //User_Master user = dbContext.User_Master.Find(task.userID);
                //user.Task_ID = task.Task_ID;
                //((IObjectContextAdapter)dbContext).ObjectContext.Detach(user);
                dbContext.Entry(parentTask).State = EntityState.Modified;
                dbContext.SaveChanges();
                return(true);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
Ejemplo n.º 2
0
        public bool AddTask(Task_Master task, ParentTask_Master parentTask)
        {
            try
            {
                var addTask       = dbContext.Task_Master.Add(task);
                var addParentTask = dbContext.ParentTask_Master.Add(parentTask);

                dbContext.SaveChanges();

                return(true);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
Ejemplo n.º 3
0
        public bool EndTask(int taskId)
        {
            try
            {
                Task_Master taskData = dbContext.Task_Master.Find(taskId);

                taskData.IsTaskEnded            = 1;
                dbContext.Entry(taskData).State = EntityState.Modified;
                dbContext.SaveChanges();
                return(true);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
Ejemplo n.º 4
0
        public Task_Master GetTaskById(int taskId)
        {
            Task_Master taskData = new Task_Master();

            try
            {
                // taskData = dbContext.Task_Master.Find(taskId);
                var Query = (from task in dbContext.Task_Master
                             join Ptask in dbContext.ParentTask_Master on task.Parent_ID equals Ptask.Parent_ID

                             into td from Task_Masters in td.DefaultIfEmpty()
                             where task.Task_ID == taskId
                             select new
                {
                    Task_ID = task.Task_ID,
                    Parent_ID = task.Parent_ID,
                    Task = task.Task,
                    StartDate = task.Start_Date,
                    EndDate = task.End_Date,
                    Priority = task.Priority,
                    IsTaskEnded = task.isTaskEnded,
                    ParentTask = Task_Masters.Parent_Task,
                    ProjectID = task.Project_Master.Project_ID,
                    //user_ID = Task_Masters.User_ID,
                }).Distinct().ToList();


                taskData = Query.ToList().Select(r => new Task_Master
                {
                    Task_ID     = r.Task_ID,
                    Parent_ID   = r.Parent_ID,
                    Task        = r.Task,
                    Start_Date  = r.StartDate,
                    End_Date    = r.EndDate,
                    Priority    = r.Priority,
                    isTaskEnded = r.IsTaskEnded,
                    ParentTask  = r.ParentTask,
                    Project_ID  = r.ProjectID,
                    userID      = dbContext.User_Master.Where(i => i.Task_ID == r.Task_ID).FirstOrDefault().User_ID
                }).FirstOrDefault();
                return(taskData);
            }
            catch (Exception ex)
            {
                return(taskData);
            }
        }
Ejemplo n.º 5
0
        public bool AddTask(Task_Master task, ParentTask_Master parentTask)
        {
            try
            {
                var         addTask       = dbContext.Task_Master.Add(task);
                var         addParentTask = dbContext.ParentTask_Master.Add(parentTask);
                User_Master user          = dbContext.User_Master.Where(i => i.User_ID == task.userID).FirstOrDefault();
                user.Project_ID = task.Project_ID;
                user.Task_ID    = addTask.Task_ID;
                dbContext.SaveChanges();

                return(true);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }