Beispiel #1
0
        public static List<SimplOrder> ToSimplOrderList(Expression<Func<Order, bool>> predicate)
        {
            var list = new List<SimplOrder>();

            using (var db = DBContextFactory.CreateContext())
            {
                //predicate = predicate.And(o => o.FilledByEntityId != null);
                var orderList = db.Orders.AsExpandable().Where(predicate);

                orderList.ForEach(order =>
                    {
                        var s = new SimplOrder
                            {
                                OrderId = order.OrderId.ToString(CultureInfo.InvariantCulture),
                                MasterOrderId = order.MasterOrderId.ToString(CultureInfo.InvariantCulture),
                                CreateDateTime = order.MasterOrder.CreateDateTime
                            };
                        var uniqueidvalue = order.MasterOrder.Entity.UniqueIds.Any() ? order.MasterOrder.Entity.UniqueIds.First().UniqueIdValue : null;
                        s.CreatorId = uniqueidvalue;
                        s.ReceiverId = order.MasterOrder.ReceivingEntityId != CustomerEntityID ?
                                           order.MasterOrder.Entity1.UniqueIds.First().UniqueIdValue :
                                           (order.ShipAddress == null ? string.Empty : order.ShipAddress1.SubscriberId);
                        s.FillLocation = order.Location.LocName;

                        if (order.FilledByEntityId != null)
                        {
                            var filledById = order.Entity.UniqueIds.FirstOrDefault();
                            s.FilledBy = filledById != null ? filledById.UniqueIdValue : string.Empty;
                        }
                        else
                        {
                            s.FilledBy = string.Empty;
                        }

                        s.FillDateTime = order.FilledDateTime;
                        var trackingNumber = order.TrackingNumbers.FirstOrDefault();
                        if (trackingNumber != null)
                            s.TrackingNumber = trackingNumber.TrackingNumber1 ?? string.Empty;
                        list.Add(s);
                    });
            }

            return list;
        }
Beispiel #2
0
        public static Order ToOrder(SimplOrder simplOrder)
        {
            var returnValue = new Order();
            if (simplOrder.OrderId != null)
                returnValue.OrderId = Utility.Conversion.QuickParse(simplOrder.OrderId); // will always be an int, so use quickparse
            if (simplOrder.MasterOrderId != null)
                returnValue.MasterOrderId = Utility.Conversion.QuickParse(simplOrder.MasterOrderId); // use quickparse as it will always be an int
            returnValue.FillLocId = StaticSimplFormats.ToLocationId(simplOrder.FillLocation);
            returnValue.FilledByEntityId = StaticSimplFormats.ToEntityId(simplOrder.FilledBy);
            returnValue.FilledDateTime = simplOrder.FillDateTime;
            returnValue.TrackingNumbers.Add(new TrackingNumber { TrackingNumber1 = simplOrder.TrackingNumber});

            return returnValue;
        }