public void CanDoPostBackEdit() { //ACT var unit = new Unit {UnitID = 1, Name = "Mt"}; var result = _unitController.Edit(unit); //Assert Assert.IsInstanceOf<ActionResult>(result); Assert.IsInstanceOf<Unit>(unit.UnitID); }
public void CanDoPostBackCreate() { //ACT var unit = new Unit {Name = "Litre"}; var result = _unitController.Create(unit); //Assert Assert.IsInstanceOf<ActionResult>(result); Assert.IsInstanceOf<int>(unit.UnitID); }
public virtual ActionResult Create(Unit unit) { if (ModelState.IsValid) { _unitService.AddUnit(unit); return Json(new { success = true }); } return PartialView(unit); }
public virtual ActionResult Edit(Unit unit) { if (ModelState.IsValid) { var origin = _unitService.FindById(unit.UnitID); origin.Name = unit.Name; _unitService.EditUnit(origin); //return RedirectToAction("Index"); return Json(new { success = true }); } ViewBag.UnitID = new SelectList(_unitService.GetAllUnit(), "UnitID", "Name", unit.UnitID); return PartialView(unit); }