public void Delete(DalTestResult entity) { var ormTestResult = entity.ToOrmTestResult(); var testResult = context.Set <TestResult>().FirstOrDefault(u => u.Id == ormTestResult.Id); context.Set <TestResult>().Attach(testResult); context.Set <TestResult>().Remove(testResult); context.Entry(testResult).State = System.Data.Entity.EntityState.Deleted; }
public void Create(DalTestResult entity) { var testResult = entity.ToOrmTestResult(); var test = context.Set <Test>().FirstOrDefault(u => u.Id == entity.TestId); var profile = context.Set <Profile>().FirstOrDefault(p => p.UserId == entity.UserId); profile.PassedTests.Add(test); context.Set <TestResult>().Add(testResult); }