Esempio n. 1
0
 private void InitDB()
 {
     using (var db = new ClientDBContext())
     {
         UIType uiType;
         uiType = new UIType
         {
             UITypeId = UIType.uiSelect,
             Name     = "Выберите"
         };
         db.Add(uiType);
         uiType = new UIType
         {
             UITypeId = UIType.uiFormula,
             Name     = "Составьте формулу"
         };
         db.Add(uiType);
         uiType = new UIType
         {
             UITypeId = UIType.uiText,
             Name     = "Введите текст"
         };
         db.Add(uiType);
         uiType = new UIType
         {
             UITypeId = UIType.uiMixed,
             Name     = "Заполните"
         };
         db.Add(uiType);
         db.SaveChanges();
     }
 }
Esempio n. 2
0
 public void SaveTaskInstance(TaskInstance taskInstance)
 {
     using (var db = new ClientDBContext())
     {
         db.TaskInstances.Update(taskInstance);
         db.SaveChanges();
     }
 }
Esempio n. 3
0
 public void DeleteTest(Test test)
 {
     try
     {
         using (var db = new ClientDBContext())
         {
             db.Tests.Remove(test);
             db.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
     }
 }
Esempio n. 4
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);
        }
Esempio n. 5
0
        private void AddTask_2()
        {
            using (var db = new ClientDBContext())
            {
                Task task = new Task
                {
                    Text = "Вчера в 9 вечера я выполнял домашнее задание."
                };
                db.Add(task);

                TaskItem parentTaskItem = new TaskItem
                {
                    TaskId     = task.TaskId,
                    LangItemId = Lib.lTense,
                    SeqNo      = 1,
                    UITypeId   = UIType.uiSelect
                };
                db.Add(parentTaskItem);
                TaskItem childTaskItem = new TaskItem
                {
                    ParentId   = parentTaskItem.TaskItemId,
                    LangItemId = Lib.lTense,
                    ValueInt   = VerbTense.vtPast,
                    UITypeId   = UIType.uiSelect
                };
                db.Add(childTaskItem);

                parentTaskItem = new TaskItem
                {
                    TaskId     = task.TaskId,
                    LangItemId = Lib.lAspect,
                    SeqNo      = 2,
                    UITypeId   = UIType.uiSelect
                };
                db.Add(parentTaskItem);
                childTaskItem = new TaskItem
                {
                    ParentId   = parentTaskItem.TaskItemId,
                    LangItemId = Lib.lAspect,
                    ValueInt   = VerbAspect.vaContinuous,
                    UITypeId   = UIType.uiSelect
                };
                db.Add(childTaskItem);


                parentTaskItem = new TaskItem
                {
                    TaskId     = task.TaskId,
                    LangItemId = Lib.lSentencePart,
                    SeqNo      = 3,
                    UITypeId   = UIType.uiFormula
                };
                db.Add(parentTaskItem);
                childTaskItem = new TaskItem
                {
                    ParentId   = parentTaskItem.TaskItemId,
                    LangItemId = Lib.lSentencePart,
                    UITypeId   = UIType.uiFormula
                };
                db.Add(childTaskItem);

                TaskItem childChildTaskItem = new TaskItem
                {
                    ParentId   = childTaskItem.TaskItemId,
                    LangItemId = Lib.lSentencePart,
                    ValueInt   = SentencePart.spOtherPart,
                    SeqNo      = 1,
                    UITypeId   = UIType.uiFormula
                };
                db.Add(childChildTaskItem);

                childChildTaskItem = new TaskItem
                {
                    ParentId   = childTaskItem.TaskItemId,
                    LangItemId = Lib.lSentencePart,
                    ValueInt   = SentencePart.spSubject,
                    SeqNo      = 2,
                    UITypeId   = UIType.uiFormula
                };
                db.Add(childChildTaskItem);

                childChildTaskItem = new TaskItem
                {
                    ParentId   = childTaskItem.TaskItemId,
                    LangItemId = Lib.lSentencePart,
                    ValueInt   = ModalVerb.mvWas,
                    SeqNo      = 3,
                    UITypeId   = UIType.uiFormula
                };
                db.Add(childChildTaskItem);

                childChildTaskItem = new TaskItem
                {
                    ParentId   = childTaskItem.TaskItemId,
                    LangItemId = Lib.lSentencePart,
                    ValueInt   = NotionalVerb.nvVing,
                    SeqNo      = 4,
                    UITypeId   = UIType.uiFormula
                };
                db.Add(childChildTaskItem);

                childChildTaskItem = new TaskItem
                {
                    ParentId   = childTaskItem.TaskItemId,
                    LangItemId = Lib.lSentencePart,
                    ValueInt   = SentencePart.spOtherPart,
                    SeqNo      = 5,
                    UITypeId   = UIType.uiFormula
                };
                db.Add(childChildTaskItem);


                parentTaskItem = new TaskItem
                {
                    TaskId     = task.TaskId,
                    LangItemId = Lib.lTranslate,
                    SeqNo      = 4,
                    UITypeId   = UIType.uiText
                };
                db.Add(parentTaskItem);
                childTaskItem = new TaskItem
                {
                    ParentId    = parentTaskItem.TaskItemId,
                    LangItemId  = Lib.lTranslate,
                    ValueString = "Yesterday at 9 pm I was doing my homework.",
                    UITypeId    = UIType.uiText
                };
                db.Add(childTaskItem);


                db.SaveChanges();
            }
        }
Esempio n. 6
0
        private void AddTask_1()
        {
            using (var db = new ClientDBContext())
            {
                Task task = new Task
                {
                    Text = "Мой брат хорошо играет в футбол."
                };
                db.Add(task);

                TaskItem parentTaskItem = new TaskItem
                {
                    TaskId     = task.TaskId,
                    LangItemId = Lib.lTense,
                    SeqNo      = 1,
                    UITypeId   = UIType.uiSelect
                };
                db.Add(parentTaskItem);
                TaskItem childTaskItem = new TaskItem
                {
                    ParentId   = parentTaskItem.TaskItemId,
                    LangItemId = Lib.lTense,
                    ValueInt   = VerbTense.vtPresent,
                    UITypeId   = UIType.uiSelect
                };
                db.Add(childTaskItem);


                parentTaskItem = new TaskItem
                {
                    TaskId     = task.TaskId,
                    LangItemId = Lib.lAspect,
                    SeqNo      = 2,
                    UITypeId   = UIType.uiSelect
                };
                db.Add(parentTaskItem);
                childTaskItem = new TaskItem
                {
                    ParentId   = parentTaskItem.TaskItemId,
                    LangItemId = Lib.lAspect,
                    ValueInt   = VerbAspect.vaSimple,
                    UITypeId   = UIType.uiSelect
                };
                db.Add(childTaskItem);


                parentTaskItem = new TaskItem
                {
                    TaskId     = task.TaskId,
                    LangItemId = Lib.lSentencePart,
                    SeqNo      = 3,
                    UITypeId   = UIType.uiFormula
                };
                db.Add(parentTaskItem);
                childTaskItem = new TaskItem
                {
                    ParentId   = parentTaskItem.TaskItemId,
                    LangItemId = Lib.lSentencePart,
                    UITypeId   = UIType.uiFormula
                };
                db.Add(childTaskItem);
                TaskItem childChildTaskItem = new TaskItem
                {
                    ParentId   = childTaskItem.TaskItemId,
                    LangItemId = Lib.lSentencePart,
                    ValueInt   = SentencePart.spOtherPart,
                    SeqNo      = 1,
                    UITypeId   = UIType.uiFormula
                };
                db.Add(childChildTaskItem);
                childChildTaskItem = new TaskItem
                {
                    ParentId   = childTaskItem.TaskItemId,
                    LangItemId = Lib.lSentencePart,
                    ValueInt   = SentencePart.spSubject,
                    SeqNo      = 2,
                    UITypeId   = UIType.uiFormula
                };
                db.Add(childChildTaskItem);
                childChildTaskItem = new TaskItem
                {
                    ParentId   = childTaskItem.TaskItemId,
                    LangItemId = Lib.lSentencePart,
                    ValueInt   = NotionalVerb.nvVs,
                    SeqNo      = 3,
                    UITypeId   = UIType.uiFormula
                };
                db.Add(childChildTaskItem);
                childChildTaskItem = new TaskItem
                {
                    ParentId   = childTaskItem.TaskItemId,
                    LangItemId = Lib.lSentencePart,
                    ValueInt   = SentencePart.spOtherPart,
                    SeqNo      = 4,
                    UITypeId   = UIType.uiFormula
                };
                db.Add(childChildTaskItem);

                childTaskItem = new TaskItem
                {
                    ParentId   = parentTaskItem.TaskItemId,
                    LangItemId = Lib.lSentencePart,
                    UITypeId   = UIType.uiFormula
                };
                db.Add(childTaskItem);
                childChildTaskItem = new TaskItem
                {
                    ParentId   = childTaskItem.TaskItemId,
                    LangItemId = Lib.lSentencePart,
                    ValueInt   = SentencePart.spSubject,
                    SeqNo      = 1,
                    UITypeId   = UIType.uiFormula
                };
                db.Add(childChildTaskItem);
                childChildTaskItem = new TaskItem
                {
                    ParentId   = childTaskItem.TaskItemId,
                    LangItemId = Lib.lSentencePart,
                    ValueInt   = NotionalVerb.nvVs,
                    SeqNo      = 2,
                    UITypeId   = UIType.uiFormula
                };
                db.Add(childChildTaskItem);
                childChildTaskItem = new TaskItem
                {
                    ParentId   = childTaskItem.TaskItemId,
                    LangItemId = Lib.lSentencePart,
                    ValueInt   = SentencePart.spOtherPart,
                    SeqNo      = 3,
                    UITypeId   = UIType.uiFormula
                };
                db.Add(childChildTaskItem);


                parentTaskItem = new TaskItem
                {
                    TaskId     = task.TaskId,
                    LangItemId = Lib.lTranslate,
                    SeqNo      = 4,
                    UITypeId   = UIType.uiText
                };
                db.Add(parentTaskItem);
                childTaskItem = new TaskItem
                {
                    ParentId    = parentTaskItem.TaskItemId,
                    LangItemId  = Lib.lTranslate,
                    ValueString = "My brother plays football well.",
                    UITypeId    = UIType.uiText
                };
                db.Add(childTaskItem);
                childTaskItem = new TaskItem
                {
                    ParentId    = parentTaskItem.TaskItemId,
                    LangItemId  = Lib.lTranslate,
                    ValueString = "My brother plays good football.",
                    UITypeId    = UIType.uiText
                };
                db.Add(childTaskItem);

                db.SaveChanges();
            }
        }