public void Delete(DalTest entity) { var ormTest = entity.ToOrmTest(); var test = context.Set <Test>().FirstOrDefault(u => u.Id == ormTest.Id); context.Set <Test>().Attach(test); context.Set <Test>().Remove(test); context.Entry(test).State = System.Data.Entity.EntityState.Deleted; }
public void Create(DalTest entity) { var test = entity.ToOrmTest(); var ormProfile = context.Set <Profile>().FirstOrDefault(u => u.UserId == test.UserId); ormProfile.CreatedTests.Add(test); context.Set <Test>().Add(test); }
public void Update(DalTest entity) { if (entity != null) { var testToUpdate = context.Set <Test>().FirstOrDefault(u => u.Id == entity.Id); var ormTest = entity.ToOrmTest(); context.Set <Test>().Attach(testToUpdate); testToUpdate.Title = ormTest.Title; testToUpdate.Description = ormTest.Description; testToUpdate.ThemeId = ormTest.ThemeId; testToUpdate.TimeLimit = ormTest.TimeLimit; testToUpdate.MinToSuccess = ormTest.MinToSuccess; testToUpdate.MinToSuccess = ormTest.MinToSuccess; context.Entry(testToUpdate).State = System.Data.Entity.EntityState.Modified; } }
public void Create(DalTest entity) { context.Tests.Add(entity.ToOrmTest()); }