Esempio n. 1
0
 public void SaveTaskInstance(TaskInstance taskInstance)
 {
     using (var db = new ClientDBContext())
     {
         db.TaskInstances.Update(taskInstance);
         db.SaveChanges();
     }
 }
Esempio n. 2
0
        public Test GenerateTest()
        {
            Test result = null;

            using (var db = new ClientDBContext())
            {
                Test test = new Test
                {
                    Date   = DateTime.Now,
                    Header = "Все подряд"
                };
                db.Add(test);

                IEnumerable <Task> tasks = db.Tasks;
                int i = 1;
                foreach (Task task in tasks)
                {
                    TaskInstance taskInstance = new TaskInstance
                    {
                        TestId = test.TestId,
                        TaskId = task.TaskId,
                        SeqNo  = i
                    };
                    db.Add(taskInstance);
                    i++;
                }

                db.SaveChanges();
                result = db.Tests.
                         Include(t1 => t1.TaskInstances).
                         ThenInclude(y1 => y1.Task).
                         ThenInclude(z1 => z1.TaskItems).
                         ThenInclude(ti1 => ti1.Children).
                         ThenInclude(cti1 => cti1.Children).
                         Include(t2 => t2.TaskInstances).
                         ThenInclude(y2 => y2.TaskItems).
                         ThenInclude(ti2 => ti2.Children).
                         Include(t3 => t3.TaskInstances).
                         ThenInclude(y3 => y3.Task).
                         ThenInclude(z3 => z3.TaskItems).
                         ThenInclude(ti3 => ti3.UIType).
                         FirstOrDefault(x => x.TestId == test.TestId);
            }
            return(result);
        }