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); } }
public CarVo insert(CarVo input) { using (var db = new MainDb()) { db.cars.Add(input); db.SaveChanges(); return(input); } }
public ActionResult Edit(Guid id, CarVo input) { if (this.ModelState.IsValid) { var res = carManager.update(input, id); return(RedirectToAction("Index")); } return(View(input)); }
public ActionResult Create(CarVo input) { if (this.ModelState.IsValid) { var item = carManager.insert(input); return(RedirectToAction("Index")); } return(View(input)); }
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); }
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); } }
public ActionResult Create() { var vo = new CarVo(); return(View(vo)); }