public void BatchDeleteTest() { Customer v1 = new Customer(); Customer v2 = new Customer(); using (var context = new DataContext(_seed, DBTypeEnum.Memory)) { v1.CustomerName = "NgFJvC0s"; v1.Contract = "hvW"; v1.ContractPhone = "wJ33Sm"; v2.CustomerName = "rQk39Lg9"; v2.Contract = "wGM"; v2.ContractPhone = "zm27JoAA"; context.Set <Customer>().Add(v1); context.Set <Customer>().Add(v2); context.SaveChanges(); } PartialViewResult rv = (PartialViewResult)_controller.BatchDelete(new string[] { v1.ID.ToString(), v2.ID.ToString() }); Assert.IsInstanceOfType(rv.Model, typeof(CustomerBatchVM)); CustomerBatchVM vm = rv.Model as CustomerBatchVM; vm.Ids = new string[] { v1.ID.ToString(), v2.ID.ToString() }; _controller.DoBatchDelete(vm, null); using (var context = new DataContext(_seed, DBTypeEnum.Memory)) { Assert.AreEqual(context.Set <Customer>().Count(), 2); } }
public void BatchEditTest() { Customer v1 = new Customer(); Customer v2 = new Customer(); using (var context = new DataContext(_seed, DBTypeEnum.Memory)) { v1.CardNum = "Ododn6F"; v1.StationId = AddStation(); v1.AreaId = AddArea(); v1.communityId = Addcommunity(); v1.buildingId = Addbuilding(); v1.Unit = "JFwD3"; v1.Room = 12; v1.CustomerName = "UGbmE"; v1.IDCard = "vVV"; v1.BuildingArea = 98; v1.HeatingArea = 92; v2.CardNum = "z5NK"; v2.StationId = v1.StationId; v2.AreaId = v1.AreaId; v2.communityId = v1.communityId; v2.buildingId = v1.buildingId; v2.Unit = "YDj5hILg"; v2.Room = 79; v2.CustomerName = "Lf2u3"; v2.IDCard = "TnIdHzjDR"; v2.BuildingArea = 28; v2.HeatingArea = 90; context.Set <Customer>().Add(v1); context.Set <Customer>().Add(v2); context.SaveChanges(); } PartialViewResult rv = (PartialViewResult)_controller.BatchDelete(new string[] { v1.ID.ToString(), v2.ID.ToString() }); Assert.IsInstanceOfType(rv.Model, typeof(CustomerBatchVM)); CustomerBatchVM vm = rv.Model as CustomerBatchVM; vm.Ids = new string[] { v1.ID.ToString(), v2.ID.ToString() }; vm.FC = new Dictionary <string, object>(); _controller.DoBatchEdit(vm, null); using (var context = new DataContext(_seed, DBTypeEnum.Memory)) { var data1 = context.Set <Customer>().Find(v1.ID); var data2 = context.Set <Customer>().Find(v2.ID); Assert.AreEqual(data1.UpdateBy, "user"); Assert.IsTrue(DateTime.Now.Subtract(data1.UpdateTime.Value).Seconds < 10); Assert.AreEqual(data2.UpdateBy, "user"); Assert.IsTrue(DateTime.Now.Subtract(data2.UpdateTime.Value).Seconds < 10); } }
public ActionResult DoBatchDelete(CustomerBatchVM vm, IFormCollection nouse) { if (!ModelState.IsValid || !vm.DoBatchDelete()) { return(PartialView("BatchDelete", vm)); } else { return(FFResult().CloseDialog().RefreshGrid().Alert("操作成功,共有" + vm.Ids.Length + "条数据被删除")); } }
public ActionResult DoBatchDelete(CustomerBatchVM vm, IFormCollection nouse) { if (!ModelState.IsValid || !vm.DoBatchDelete()) { return(PartialView("BatchDelete", vm)); } else { return(FFResult().CloseDialog().RefreshGrid().Alert(Localizer["Sys.BatchDeleteSuccess", vm.Ids.Length])); } }