Пример #1
0
 public void insertRecordsTest()
 {
     for (int i = 1; i <= 10; i++)
     {
         var vo = new CarVo();
         vo.millage = i * 1234;
         //vo.name = i.ToString() + " Test BusinessCategoryType Name ";
         var result = carManager.insert(vo);
         if (result == null)
         {
             Assert.IsTrue(false);
             break;
         }
     }
     Assert.IsTrue(true);
 }
Пример #2
0
        public void insertDeleteTest()
        {
            var vo = new CarVo();
            vo.millage = 32500;

            var result = carManager.insert(vo);
            var result2 = carManager.get(result.carId);

            carManager.delete(result.carId);

            var result3 = carManager.get(result.carId);

            if (result != null && result2 != null && result3 == null && result2.carId != Guid.Empty)
            {
                Assert.IsTrue(true);
            }
            else
                Assert.IsTrue(false);
        }
Пример #3
0
        public CarVo insert(CarVo input)
        {
            using (var db = new MainDb())
            {

                db.cars.Add(input);
                db.SaveChanges();

                return input;
            }
        }
Пример #4
0
        public CarVo update(CarVo input, Guid? carId= null)
        {
            using (var db = new MainDb())
            {

                if (carId == null)
                    carId = input.carId;

                var res = db.cars.FirstOrDefault(e => e.carId == carId);

                if (res == null) return null;

                input.created = res.created;
               // input.createdBy = res.createdBy;
                db.Entry(res).CurrentValues.SetValues(input);

                db.SaveChanges();
                return res;

            }
        }