public void SaveAnswer(Answer answer) { if (answer.Id == 0) { context.Answers.Add(answer); } else { context.Entry(answer).State = Microsoft.EntityFrameworkCore.EntityState.Modified; } context.SaveChanges(); }
public void SaveQuestion(Question question) { if (question.Id == 0) { context.Questions.Add(question); } else { context.Entry(question).State = Microsoft.EntityFrameworkCore.EntityState.Modified; } context.SaveChanges(); }
public void SaveTest(Test test) { if (test.Id == 0) { test.CreatedAt = DateTime.Now; test.ReferrerToken = Guid.NewGuid(); context.Tests.Add(test); } else { context.Entry(test).State = Microsoft.EntityFrameworkCore.EntityState.Modified; } context.SaveChanges(); }