Exemplo n.º 1
0
        public void ProcessRequest(HttpContext context)
        {
            TaskDBEntities taskDB = new TaskDBEntities();
            string updatedTasks = context.Request["updatedTasks"];
            JavaScriptSerializer taskListSerilizer = new JavaScriptSerializer();
            List<Task> updatedTaskList = (List<Task>)taskListSerilizer.Deserialize(updatedTasks, typeof(List<Task>));

            List<Task> ClonedSouece = taskDB.Tasks.ToList();
            foreach (Task updatedtask in updatedTaskList)
            {
                Task task = taskDB.Tasks.Where(t => t.ID == updatedtask.ID).SingleOrDefault();
                task.AssignedResources = updatedtask.AssignedResources;
                task.Description = updatedtask.Description;
                task.EndDate = updatedtask.EndDate;
                task.IndentLevel = updatedtask.IndentLevel;
                task.PredecessorIndices = updatedtask.PredecessorIndices;
                task.PreferredStartTime = updatedtask.PreferredStartTime;
                task.ProgressPercent = updatedtask.ProgressPercent;
                task.SortOrder = updatedtask.SortOrder;
                task.StartDate = updatedtask.StartDate;
                task.TaskName = updatedtask.TaskName;
                task.AssignedResources = updatedtask.AssignedResources;

                taskDB.Entry(task).State = EntityState.Modified;
            }
            taskDB.SaveChanges();
            context.Response.Write("success");
        }
Exemplo n.º 2
0
        //Gantt Code 1 :  Create the DataSource for the gantt. Here It will get the data from the database.
        public void ProcessRequest(HttpContext context)
        {
            TaskDBEntities taskDB = new TaskDBEntities();
            List<Task> taskItems = taskDB.Tasks.ToList();

            JavaScriptSerializer serializer = new JavaScriptSerializer();
            context.Response.Write(serializer.Serialize(taskItems));
        }
Exemplo n.º 3
0
        public void ProcessRequest(HttpContext context)
        {
            TaskDBEntities taskDB = new TaskDBEntities();
            string addedTasks = context.Request["addedTasks"];
            JavaScriptSerializer taskListSerilizer = new JavaScriptSerializer();
            Task task = (Task)taskListSerilizer.Deserialize(addedTasks, typeof(Task));

            taskDB.Tasks.Add(task);
            taskDB.SaveChanges();
            context.Response.Write("success");
        }
Exemplo n.º 4
0
        public void ProcessRequest(HttpContext context)
        {
            TaskDBEntities taskDB = new TaskDBEntities();
            string addedTasks = context.Request["addedTasks"];
            string removedTaskIds = context.Request["removedTaskIds"];
            string updatedTasks = context.Request["updatedTasks"];
            JavaScriptSerializer taskListSerilizer = new JavaScriptSerializer();
            List<Task> addedtaskList = (List<Task>)taskListSerilizer.Deserialize(addedTasks, typeof(List<Task>));
            List<Task> updatedTaskList = (List<Task>)taskListSerilizer.Deserialize(updatedTasks, typeof(List<Task>));
            List<int> rIds = (List<int>)taskListSerilizer.Deserialize(removedTaskIds, typeof(List<int>));

            List<Task> ClonedSouece = taskDB.Tasks.ToList();
            List<Task> removeableTasks = (from task in ClonedSouece where rIds.Contains(task.ID) select task).ToList();
            List<int> addedTaskIds = (from task in addedtaskList select task.ID).ToList();
            //To remove the tasks from DB
            foreach (Task task in removeableTasks)
            taskDB.Tasks.Remove(task);
            //To add the tasks to DB
            foreach (Task task in addedtaskList)
            {
            if (rIds.Contains(task.ID) == false && removeableTasks.Contains(task) == false)
            taskDB.Tasks.Add(task);
            }

            //To check the updates task is removed or added, if that does means we just ignore to update DB
            updatedTaskList = (from task in updatedTaskList where !rIds.Contains(task.ID) && !addedTaskIds.Contains(task.ID) select task).ToList();

            foreach (Task updatedtask in updatedTaskList)
            {
            Task task = taskDB.Tasks.Where(t => t.ID == updatedtask.ID).SingleOrDefault();
            task.AssignedResources = updatedtask.AssignedResources;
            task.Description = updatedtask.Description;
            task.EndDate = updatedtask.EndDate;
            task.IndentLevel = updatedtask.IndentLevel;
            task.PredecessorIndices = updatedtask.PredecessorIndices;
            task.PreferredStartTime = updatedtask.PreferredStartTime;
            task.ProgressPercent = updatedtask.ProgressPercent;
            task.SortOrder = updatedtask.SortOrder;
            task.StartDate = updatedtask.StartDate;
            task.TaskName = updatedtask.TaskName;
            task.AssignedResources = updatedtask.AssignedResources;

            taskDB.Entry(task).State = EntityState.Modified;
            }
            taskDB.SaveChanges();
            context.Response.Write("success");
        }
Exemplo n.º 5
0
        public void ProcessRequest(HttpContext context)
        {
            TaskDBEntities taskDB = new TaskDBEntities();
            string removedTaskIds = context.Request["removedTaskIds"];
            JavaScriptSerializer taskListSerilizer = new JavaScriptSerializer();
            List<int> rIds = (List<int>)taskListSerilizer.Deserialize(removedTaskIds, typeof(List<int>));

            List<Task> ClonedSouece = taskDB.Tasks.ToList();
            List<Task> removeableTasks = (from task in ClonedSouece where rIds.Contains(task.ID) select task).ToList();
            //To remove the tasks from DB
            foreach (Task task in removeableTasks)
                taskDB.Tasks.Remove(task);
            //To remove the tasks from DB
            foreach (Task task in removeableTasks)
                taskDB.Tasks.Remove(task);
            taskDB.SaveChanges();
        }