TopShelfCustomer/TopShelfCustomer.Api/Controllers/OrderController.cs
/// <summary>
/// GetOrdersByEmail:
///
/// Method responsible for the "GetOrdersByEmail"
/// API endpoint. Uses helper classes to return the
/// correct collection of Orders to the API caller.
/// </summary>
/// <param name="email"> The email to match </param>
/// <returns> A list of orders for the account associated with "email" </returns>
/// <remarks>
/// Endpoints cannot handle the '.' operator. The caller must replace '.' with '-' before fetching
/// User.
/// </remarks>


Method responsible for the "GetOrdersByEmail"
API endpoint. Uses helper classes to return the
correct collection of Orders to the API caller.
Method responsible for the " GetOrdersByEmail " API endpoint . Uses helper classes to return the correct collection of Orders to the API caller .
[Route( "api/Order/GetOrdersByEmail/{email}" )]
        [HttpGet]
        public IEnumerable<Order> GetOrdersByEmail ( string email ) {
            OrderData data = new OrderData();
            string sanitizedEmail = email.Replace( "-", "." );      
            var orders = data.GetOrdersByEmail( sanitizedEmail );
            try {               
                if ( orders[0] == null ) { return new List<Order>(); }
            } catch ( ArgumentOutOfRangeException e ) {
                Debug.WriteLine( e.Message );
                return new List<Order>();
            } catch ( Exception e ) {
                Debug.WriteLine( e.Message );
                return new List<Order>();
            }
            return orders;
        }
[ Route ( " " ) ] [ HttpGet ] public IEnumerable < Order > GetOrdersByEmail ( string email ) { OrderData data = new OrderData ( ) ; string sanitizedEmail = email . Replace ( " " , " " ) ; var orders = data . GetOrdersByEmail ( sanitizedEmail ) ; try { if ( orders [ 0 ] == null ) { return new List < Order > ( ) ; } } catch ( ArgumentOutOfRangeException e ) { Debug . WriteLine ( e . Message ) ; return new List < Order > ( ) ; } catch ( Exception e ) { Debug . WriteLine ( e . Message ) ; return new List < Order > ( ) ; } return orders ; }
GetOrdersByEmail:
GetOrdersByEmail :
//Convert from url-friendly email back to correct format //Catch exceptions thrown by null User
A list of orders for the account associated with "email"
A list of orders for the account associated with " email "
email
string
The email to match
The email to match
remarks
Endpoints cannot handle the '.' operator. The caller must replace '.' with '-' before fetching
User.
Endpoints cannot handle the ' . ' operator . The caller must replace ' . ' with ' - ' before fetching User .