public ActionResult Delete(int id) { if (_rep.Delete(id) == 1) { TempData["SuccessMessage"] = NameHandling.SuccessMessageDelete; } else { TempData["ErrorMessage"] = NameHandling.ErrorMessage; } return(RedirectToAction("Index")); }
public void VehicleTypeTestsAllInOneMethod() { using (TransactionScope scope = new TransactionScope()) { var fixture = new Fixture(); var autoVehicleType = fixture.Create <VehicleType>(); IVehicleTypeRepository vtRep = new VehicleTypeRepository(); vtRep.Save(autoVehicleType); var insertedVehicleType = vtRep.GetById(autoVehicleType.VehicleTypeId); Assert.AreEqual(insertedVehicleType.VehicleTypeName, autoVehicleType.VehicleTypeName); IEnumerable <VehicleType> vtList = vtRep.GetAll().Where(v => v.VehicleTypeId == autoVehicleType.VehicleTypeId); Assert.AreEqual(vtList.Count(), 1); vtRep.Delete(autoVehicleType); var deletedVehicleType = vtRep.GetById(autoVehicleType.VehicleTypeId); Assert.IsNull(deletedVehicleType); } }
public IActionResult DeleteType(int id) { repo.Delete(id); return(RedirectToAction("ViewVehicleTypes")); }