public void Create(DalQuestion entity)
 {
     if (entity != null)
     {
         context.Questions.Add(entity.ToOrmQuestion());
     }
 }
Exemple #2
0
        public void CreateAndUpdateTestId(DalQuestion entity, int testId)
        {
            var question = entity.ToOrmQuestion();
            var test     = context.Set <Test>().FirstOrDefault(t => t.Id == testId);

            test.Questions.Add(question);
            context.Set <Question>().Add(question);
        }
Exemple #3
0
        public void Delete(DalQuestion entity)
        {
            var ormQuestion = entity.ToOrmQuestion();
            var question    = context.Set <Question>().FirstOrDefault(u => u.Id == ormQuestion.Id);

            context.Set <Question>().Attach(question);
            context.Set <Question>().Remove(question);
            context.Entry(question).State = System.Data.Entity.EntityState.Deleted;
        }
Exemple #4
0
 public void Update(DalQuestion entity)
 {
     if (entity != null)
     {
         var questionToUpdate = context.Set <Question>().FirstOrDefault(u => u.Id == entity.Id);
         var ormQuestion      = entity.ToOrmQuestion();
         context.Set <Question>().Attach(questionToUpdate);
         questionToUpdate.Text = ormQuestion.Text;
         context.Entry(questionToUpdate).State = System.Data.Entity.EntityState.Modified;
     }
 }
Exemple #5
0
        public void Create(DalQuestion entity)
        {
            var question = entity.ToOrmQuestion();

            context.Set <Question>().Add(question);
        }