internal bool IsAvailable(string stockCode)
 {
     try
     {
         IPartAvailabilityService _PartAvailabilityServiceClient = _PartAvailabilityServiceFactory.CreateClient();
         int availability = _PartAvailabilityServiceClient.GetAvailability(stockCode);
         if (availability <= 0)
         {
             return(false);
         }
         return(true);
     }
     catch (System.Exception)
     {
         throw;
     }
     finally
     {
         _PartAvailabilityServiceFactory.CloseClient();
     }
 }
예제 #2
0
 /// <summary>
 /// Checks to see if enough of the product is in stock
 /// - this was originally only checking if something was in stock,
 //  - but that didn't seem like the correct behaviour
 /// </summary>
 /// <param name="stockCode">stock code</param>
 /// <param name="minimumQuanitity">minimum quantity required</param>
 /// <returns></returns>
 public static bool EnoughOfTheProductIsInStock(this IPartAvailabilityService client, string stockCode, int minimumQuanitity = 0)
 {
     return(client.GetAvailability(stockCode) >= minimumQuanitity);
 }
 private bool IsInValidRequest(string stockCode, int quantity)
 {
     return(quantity <= 0 ||
            string.IsNullOrEmpty(stockCode) ||
            PartAvailabilityService.GetAvailability(stockCode) <= 0);
 }