public void DeleteTest() { SmallEntEvaluationBase v = new SmallEntEvaluationBase(); using (var context = new DataContext(_seed, DBTypeEnum.Memory)) { v.Status = Model.Common.EvaluationStatus.Completed; context.Set <SmallEntEvaluationBase>().Add(v); context.SaveChanges(); } PartialViewResult rv = (PartialViewResult)_controller.Delete(v.ID.ToString()); Assert.IsInstanceOfType(rv.Model, typeof(SmallEntEvaluationBaseVM)); SmallEntEvaluationBaseVM vm = rv.Model as SmallEntEvaluationBaseVM; v = new SmallEntEvaluationBase(); v.ID = vm.Entity.ID; vm.Entity = v; _controller.Delete(v.ID.ToString(), null); using (var context = new DataContext(_seed, DBTypeEnum.Memory)) { Assert.AreEqual(context.Set <SmallEntEvaluationBase>().Count(), 1); } }
public ActionResult Edit(SmallEntEvaluationBaseVM vm) { if (!ModelState.IsValid) { return(PartialView(vm)); } else { vm.DoEdit(); if (!ModelState.IsValid) { vm.DoReInit(); return(PartialView(vm)); } else { return(FFResult().CloseDialog().RefreshGridRow(vm.Entity.ID)); } } }
public void CreateTest() { PartialViewResult rv = (PartialViewResult)_controller.Create(); Assert.IsInstanceOfType(rv.Model, typeof(SmallEntEvaluationBaseVM)); SmallEntEvaluationBaseVM vm = rv.Model as SmallEntEvaluationBaseVM; SmallEntEvaluationBase v = new SmallEntEvaluationBase(); v.Status = Model.Common.EvaluationStatus.Completed; vm.Entity = v; _controller.Create(vm); using (var context = new DataContext(_seed, DBTypeEnum.Memory)) { var data = context.Set <SmallEntEvaluationBase>().FirstOrDefault(); Assert.AreEqual(data.Status, 43); Assert.AreEqual(data.CreateBy, "user"); Assert.IsTrue(DateTime.Now.Subtract(data.CreateTime.Value).Seconds < 10); } }
public void EditTest() { SmallEntEvaluationBase v = new SmallEntEvaluationBase(); using (var context = new DataContext(_seed, DBTypeEnum.Memory)) { v.Status = Model.Common.EvaluationStatus.Completed; context.Set <SmallEntEvaluationBase>().Add(v); context.SaveChanges(); } PartialViewResult rv = (PartialViewResult)_controller.Edit(v.ID.ToString()); Assert.IsInstanceOfType(rv.Model, typeof(SmallEntEvaluationBaseVM)); SmallEntEvaluationBaseVM vm = rv.Model as SmallEntEvaluationBaseVM; v = new SmallEntEvaluationBase(); v.ID = vm.Entity.ID; v.Status = Model.Common.EvaluationStatus.Completed; vm.Entity = v; vm.FC = new Dictionary <string, object>(); vm.FC.Add("Entity.Status", ""); _controller.Edit(vm); using (var context = new DataContext(_seed, DBTypeEnum.Memory)) { var data = context.Set <SmallEntEvaluationBase>().FirstOrDefault(); Assert.AreEqual(data.Status, 74); Assert.AreEqual(data.UpdateBy, "user"); Assert.IsTrue(DateTime.Now.Subtract(data.UpdateTime.Value).Seconds < 10); } }
public IActionResult SearchUser(SmallEntEvaluationBaseVM vm, string keywords) { return(Json(vm.SearchUser(keywords))); }