public Business.Entities.Test GetTest(int testId) { var dbContext = _context.GetInstance(); var test = dbContext.Tests.FirstOrDefault(x => x.Id == testId); return(TestMapper.MapDalToEntity(test)); }
public void AddTest(ref Business.Entities.Test test) { var dbContext = _context.GetInstance(); var testToAdd = TestMapper.MapEntityToDal(test); dbContext.Tests.Add(testToAdd); dbContext.SaveChanges(); test = TestMapper.MapDalToEntity(testToAdd); }
public void UpdateTest(ref Business.Entities.Test test) { var dbContext = _context.GetInstance(); var newTest = TestMapper.MapEntityToDal(test); var testFromDb = dbContext.Tests.FirstOrDefault(x => x.Id == newTest.Id); testFromDb = (Test)UpdateEntity(testFromDb, newTest); dbContext.SaveChanges(); test = TestMapper.MapDalToEntity(testFromDb); }