Esempio n. 1
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);
        }
Esempio n. 2
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);
        }