Beispiel #1
0
 /// <summary>
 /// Checks whether provided event is expected according to this itinerary specification.
 /// </summary>
 /// <param name="event">A handling event.</param>
 /// <returns>True, if it is expected. Otherwise - false. If itinerary is empty, returns false.</returns>
 public virtual bool IsExpected(HandlingEvent @event)
 {
     if (IsEmpty)
     {
         return(false);
     }
     if (@event.EventType == HandlingEventType.Receive)
     {
         Leg firstLeg = Legs.First();
         return(firstLeg.LoadLocation == @event.Location);
     }
     if (@event.EventType == HandlingEventType.Claim)
     {
         Leg lastLeg = Legs.Last();
         return(lastLeg.UnloadLocation == @event.Location);
     }
     if (@event.EventType == HandlingEventType.Load)
     {
         return(Legs.Any(x => x.LoadLocation == @event.Location));
     }
     if (@event.EventType == HandlingEventType.Unload)
     {
         return(Legs.Any(x => x.UnloadLocation == @event.Location));
     }
     //@event.EventType == HandlingEventType.Customs
     return(true);
 }
        /// <summary>
        /// Determines if a given request for quote matches the filter criteria.
        /// </summary>
        /// <param name="criteria">the filter criteria.</param>
        /// <returns>true if the request for quote matches the filter criteria.</returns>
        /// <exception cref="ArgumentNullException">if the filter criteria is null or includes an invalid date.</exception>
        public bool DoesRequestMatchFilter(Dictionary <string, string> criteria)
        {
            if (criteria == null)
            {
                throw new ArgumentNullException("criteria");
            }

            foreach (var criterion in criteria)
            {
                switch (criterion.Key)
                {
                case RequestForQuoteConstants.CLIENT_CRITERION:
                    int clientIdentifier;
                    if (!int.TryParse(criterion.Value, out clientIdentifier) || Client.Identifier != clientIdentifier)
                    {
                        return(false);
                    }
                    break;

                case RequestForQuoteConstants.BOOK_CRITERION:
                    if (BookCode != criterion.Value)
                    {
                        return(false);
                    }
                    break;

                case RequestForQuoteConstants.UNDERLYIER_CRITERION:
                    if (Legs == null)
                    {
                        return(false);
                    }
                    var underlyierExists = Legs.Any(leg => leg.RIC == criterion.Value);
                    if (!underlyierExists)
                    {
                        return(false);
                    }
                    break;

                case RequestForQuoteConstants.STATUS_CRITERION:
                    if (Status != (StatusEnum)Enum.Parse(typeof(StatusEnum), criterion.Value))
                    {
                        return(false);
                    }
                    break;

                case RequestForQuoteConstants.TRADE_DATE_CRITERION:
                    try
                    {
                        if (!UtilityMethods.IsWithinDateRange(TradeDate, criterion.Value))
                        {
                            return(false);
                        }
                    }
                    catch (Exception)
                    {
                        throw new ArgumentException("criteria");
                    }
                    break;

                case RequestForQuoteConstants.EXPIRY_DATE_CRITERION:
                    try
                    {
                        if (!UtilityMethods.IsWithinDateRange(ExpiryDate, criterion.Value))
                        {
                            return(false);
                        }
                    }
                    catch (Exception)
                    {
                        throw new ArgumentException("criteria");
                    }
                    break;

                default:
                    return(false);
                }
            }
            return(true);
        }