public void Create(DalQuestion entity) { if (entity != null) { context.Questions.Add(entity.ToOrmQuestion()); } }
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); }
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; }
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; } }
public void Create(DalQuestion entity) { var question = entity.ToOrmQuestion(); context.Set <Question>().Add(question); }