예제 #1
0
        public Business.Entities.Test GetTest(int testId)
        {
            var dbContext = _context.GetInstance();
            var test      = dbContext.Tests.FirstOrDefault(x => x.Id == testId);

            return(TestMapper.MapDalToEntity(test));
        }
예제 #2
0
        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);
        }
예제 #3
0
        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);
        }