TopShelfCustomer/TopShelfCustomer.Api/Controllers/StoreController.cs
/// <summary>
/// GetStoresByZipCode:
///
/// Fetches all Stores with matching ZipCode and returns
/// them to the API caller.
/// </summary>
/// <param name="zipCode"> The Store ZipCode to match </param>
/// <returns> A List of Stores </returns>


Fetches all Stores with matching ZipCode and returns
them to the API caller.
Fetches all Stores with matching ZipCode and returns them to the API caller .
[Route( "api/Store/GetStoreByZipCode/{zipCode:int}" )]
        [HttpGet]
        public IEnumerable<Store> GetStoresByZipCode ( int zipCode ) {
            StoreData data = new StoreData();
            var stores = data.GetStoresByZipCode( zipCode );
            try {               
                if ( stores[0] == null ) { return new List<Store>(); }
            } catch ( ArgumentOutOfRangeException e ) {
                Debug.WriteLine( e.Message );
                return new List<Store>();
            } catch ( Exception e ) {
                Debug.WriteLine( e.Message );
                return new List<Store>();
            }
            return stores;
        }
[ Route ( " " ) ] [ HttpGet ] public IEnumerable < Store > GetStoresByZipCode ( int zipCode ) { StoreData data = new StoreData ( ) ; var stores = data . GetStoresByZipCode ( zipCode ) ; try { if ( stores [ 0 ] == null ) { return new List < Store > ( ) ; } } catch ( ArgumentOutOfRangeException e ) { Debug . WriteLine ( e . Message ) ; return new List < Store > ( ) ; } catch ( Exception e ) { Debug . WriteLine ( e . Message ) ; return new List < Store > ( ) ; } return stores ; }
GetStoresByZipCode:
GetStoresByZipCode :
//Catch exceptions thrown by null Products
A List of Stores
A List of Stores
zipCode
int
The Store ZipCode to match
The Store ZipCode to match