/// <summary> /// This method fetches a 'List<ZipCode>' object. /// This method uses the 'ZipCodes_FetchAll' procedure. /// </summary> /// <returns>A 'List<ZipCode>'</returns> /// </summary> public List <ZipCode> FetchAllZipCodes(FetchAllZipCodesStoredProcedure fetchAllZipCodesProc, DataConnector databaseConnector) { // Initial Value List <ZipCode> zipCodeCollection = null; // Verify database connection is connected if ((databaseConnector != null) && (databaseConnector.Connected)) { // First Get Dataset DataSet allZipCodesDataSet = this.DataHelper.LoadDataSet(fetchAllZipCodesProc, databaseConnector); // Verify DataSet Exists if (allZipCodesDataSet != null) { // Get DataTable From DataSet DataTable table = this.DataHelper.ReturnFirstTable(allZipCodesDataSet); // if table exists if (table != null) { // Load Collection zipCodeCollection = ZipCodeReader.LoadCollection(table); } } } // return value return(zipCodeCollection); }
/// <summary> /// This method finds a 'ZipCode' object. /// This method uses the 'ZipCode_Find' procedure. /// </summary> /// <returns>A 'ZipCode' object.</returns> /// </summary> public ZipCode FindZipCode(FindZipCodeStoredProcedure findZipCodeProc, DataConnector databaseConnector) { // Initial Value ZipCode zipCode = null; // Verify database connection is connected if ((databaseConnector != null) && (databaseConnector.Connected)) { // First Get Dataset DataSet zipCodeDataSet = this.DataHelper.LoadDataSet(findZipCodeProc, databaseConnector); // Verify DataSet Exists if (zipCodeDataSet != null) { // Get DataTable From DataSet DataRow row = this.DataHelper.ReturnFirstRow(zipCodeDataSet); // if row exists if (row != null) { // Load ZipCode zipCode = ZipCodeReader.Load(row); } } } // return value return(zipCode); }
public void TestReadingZipCodeFile() { // Arrange ZipCodeReader reader = new ZipCodeReader(); // Act List <ZipCodeInfo> zipCodes = reader.LoadZipCodes("ZipCodes.csv"); // Assert Assert.NotEmpty(zipCodes); }
public static void Configure() { var builder = new ContainerBuilder(); builder.RegisterControllers(typeof(MvcApplication).Assembly); // Zip Code Service ZipCodeReader reader = new ZipCodeReader(); String filename = Path.Combine(HttpRuntime.BinDirectory, "zipcodes.csv"); var zipCodeService = new InMemoryZipCodeService(reader.LoadZipCodes(filename)); builder.RegisterInstance <IZipCodeService>(zipCodeService).As <IZipCodeService>(); //builder.RegisterType<WeatherUndergroundDriver>().As<IWeatherClient>(); //builder.RegisterType<NoaaWeatherDriver>().As<IWeatherClient>(); // For Decorators // http://docs.autofac.org/en/latest/advanced/adapters-decorators.html // Register the services to be decorated. You have to // name them rather than register them As<IWeatherClient>() // so the *decorator* can do the registration for As<IWeatherClient>() //builder.RegisterType<WeatherUndergroundDriver>().Named<IWeatherClient>("weather"); builder.RegisterType <NoaaWeatherDriver>().Named <IWeatherClient>("weather"); // Register the decorator. The decorator uses the named registrations to get the items to wrap. builder.RegisterDecorator <IWeatherClient>( (c, inner) => new WeatherClientCacheDecorator(inner), fromKey: "weather"); var container = builder.Build(); DependencyResolver.SetResolver(new AutofacDependencyResolver(container)); }