public static Question FromDbModel(QuestionDbModel model) { return(new Question { Id = model.Id, TestId = model.TestId, Text = model.Text, }); }
public void QuestionDelete(QuestionDbModel item) { var model = questions.FirstOrDefault(i => i.Id == item.Id); if (model != null) { Entry(model).State = EntityState.Detached; Entry(item).State = EntityState.Deleted; } }
public void QuestionInsert(QuestionDbModel item) { var model = questions.FirstOrDefault(i => i.Id == item.Id); if (model != null) { Entry(model).State = EntityState.Detached; Entry(item).State = EntityState.Modified; } else { questions.Add(item); } SaveChanges(); }