public void ProcessResult(CheckResult result, Order dbOrder) { if (result.IsSuccess) { if (ShippingUtils.IsCanada(dbOrder.ShippingCountry)) { _log.Debug("IsPrime = false because of Canada"); dbOrder.OrderType = (int)OrderTypeEnum.Default; } } //TASK: Remove automatic hold //if (result.IsSuccess) //{ // _log.Debug("Set OnHold by CheckPrime"); // dbOrder.OnHold = true; //} }
public CheckResult Check(IUnitOfWork db, DTOMarketOrder order, IList <ListingOrderDTO> items, AddressValidationStatus addressValidationStatus) { if (order.Id == 0) { throw new ArgumentOutOfRangeException("order.Id", "Should be non zero"); } if (order.OrderStatus == OrderStatusEnumEx.Pending) { throw new ArgumentException("order.OrderStatus", "Not supported status Pending"); } if (ShippingUtils.IsCanada(order.FinalShippingCountry)) { var state = order.FinalShippingState; if ((state ?? "").Length > 2) { var stateAbbr = db.States.GetCodeByName(state); if (!String.IsNullOrEmpty(stateAbbr)) { return(new CheckResult() { IsSuccess = true, AdditionalData = new[] { stateAbbr } }); } } } return(new CheckResult() { IsSuccess = false }); }
public IList<TrackingState> TrackShipments(IList<TrackingNumberToCheckDto> trackingNumbers) { var uspsResults = _uspsProvider.TrackShipments(trackingNumbers); var canadaPostResults = _canadaPostProvider.TrackShipments(trackingNumbers.Where(t => ShippingUtils.IsCanada(t.ToCountry)).ToList()); //TODO: compose by date foreach (var trackingNumber in trackingNumbers) { var uspsResult = uspsResults.FirstOrDefault(r => r.TrackingNumber == trackingNumber.TrackingNumber); var canadaPostResult = canadaPostResults.FirstOrDefault(r => r.TrackingNumber == trackingNumber.TrackingNumber); if (uspsResult != null && uspsResult.Records != null && uspsResult.Records.Any() && canadaPostResult != null && canadaPostResult.Records != null && canadaPostResult.Records.Any()) { _log.Info("Has both CA ans USPS results"); var lastUspsRecordDate = uspsResult.Records.Max(r => r.Date); if (lastUspsRecordDate < canadaPostResult.Records.Max(r => r.Date)) { _log.Info("Add CA tracking results"); uspsResult.Records.AddRange(canadaPostResult.Records.Where(r => r.Date > lastUspsRecordDate).ToList()); uspsResult.Records = uspsResult.Records.OrderByDescending(r => r.Date).ToList(); } } } return uspsResults; }