public void Create(DalUsersTest e) { if (context.Database.Connection.State != ConnectionState.Open) context.Database.Connection.Open(); UsersTests ut = new UsersTests() { id = e.Id, BeginningTime = e.BeginningTime, EndingTime = e.EndingTime, MarkForTest = e.MarkForTest, RightAnswersCount = e.RightAnswersCount, TestId = e.TestId, UserId = e.UserId }; context.Set<UsersTests>().Add(ut); }
public void StartTest(DalUser user, DalTest test) { if (IsUserTested(user)) return; Users ormuser = context.Set<Users>().FirstOrDefault(users => users.id == user.Id); Tests ormtest = context.Set<Tests>().FirstOrDefault(tests => tests.id == test.Id); UsersTests startingTest = new UsersTests() { TestId = ormtest.id, BeginningTime = DateTime.Now, EndingTime = null, MarkForTest = null, RightAnswersCount = null, UserId = ormuser.id }; context.Set<UsersTests>().Add(startingTest); }