public bool DeleteUnit(Unit unit) { if (unit == null) return false; _unitOfWork.UnitRepository.Delete(unit); _unitOfWork.Save(); return true; }
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); }
public bool EditUnit(Unit unit) { _unitOfWork.UnitRepository.Edit(unit); _unitOfWork.Save(); return true; }
public bool AddUnit(Unit unit) { _unitOfWork.UnitRepository.Add(unit); _unitOfWork.Save(); return true; }
private Unit BindUnit(UnitViewModel model) { if (model == null) return null; var unit = new Unit() { UnitID = model.UnitID, Name = model.UnitName }; return unit; }