public IEnumerable <VehicleType> GetAllVehicleTypes() { VehicleTypeRepository repo = new VehicleTypeRepository(CONNECTION_STRING); IEnumerable <VehicleType> vehicleTypes = default(IEnumerable <VehicleType>); vehicleTypes = repo.GetAll(); return(vehicleTypes); }
private void PopulateVehicleTypesDropDownList(object selectedVehicleType = null) { IVehicleTypeRepository vtRep = new VehicleTypeRepository(); var vehicletypesQuery = from d in vtRep.GetAll() orderby d.VehicleTypeName select d; ViewBag.VehicleTypeID = new SelectList(vehicletypesQuery, "VehicleTypeID", "VehicleTypeName", selectedVehicleType); }
public void CanLoadVehicleTypes() { var repo = new VehicleTypeRepository(); var types = repo.GetAll(); Assert.AreEqual(2, types.Count()); Assert.AreEqual("New", types[0].VehicleTypeName); Assert.AreEqual("Used", types[1].VehicleTypeName); }
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 List <VehicleType> GetVehicleType() { VehicleTypeRepository RepositoryObj = new VehicleTypeRepository(CONNECTION_STRING); return(RepositoryObj.GetAll().ToList <VehicleType>()); }