TopShelfCustomer/TopShelfCustomer.Api/Controllers/CouponController.cs
/// <summary>
/// GetCouponByZipCode:
///
/// Handler for Http GET calls fetching
/// the coupons for a given Store area (by Zip Code).
/// </summary>
/// <returns></returns>


Handler for Http GET calls fetching
the coupons for a given Store area (by Zip Code).
Handler for Http GET calls fetching the coupons for a given Store area ( by Zip Code ) .
[Route( "api/Coupon/GetCouponsByZipCode/{zipCode:int}" )]
        [HttpGet]
        public IEnumerable<Coupon> GetCouponsByZipCode ( int zipCode ) {
            CouponData data = new CouponData();
            var coupons = data.GetCouponsByZipCode( zipCode );      
            try {               
                if ( coupons == null ) { return new List<Coupon>(); }
            } catch ( ArgumentOutOfRangeException e ) {
                Debug.WriteLine( e.Message );
                return new List<Coupon>();
            } catch ( Exception e ) {
                Debug.WriteLine( e.Message );
                return new List<Coupon>();
            }
            return coupons;
        }
[ Route ( " " ) ] [ HttpGet ] public IEnumerable < Coupon > GetCouponsByZipCode ( int zipCode ) { CouponData data = new CouponData ( ) ; var coupons = data . GetCouponsByZipCode ( zipCode ) ; try { if ( coupons == null ) { return new List < Coupon > ( ) ; } } catch ( ArgumentOutOfRangeException e ) { Debug . WriteLine ( e . Message ) ; return new List < Coupon > ( ) ; } catch ( Exception e ) { Debug . WriteLine ( e . Message ) ; return new List < Coupon > ( ) ; } return coupons ; }
GetCouponByZipCode:
GetCouponByZipCode :
//Fetch the List of coupons from the db wrapper class //Catch exceptions thrown by null User
None
zipCode
int