Example #1
0
 public static ShipmentMapper MapShipment(this ShipmentMapper shipmentMapper, string shipment)
 {
     return(JsonConvert.DeserializeObject <ShipmentMapper>(shipment, new JsonSerializerSettings()
     {
         Culture = CultureInfo.CurrentCulture
     }));
 }
Example #2
0
        private static ShipmentMapper MapShipmentMapperToShipment(this ShipmentMapper shipmentMapper, Shipment shipment)
        {
            //Shipment
            shipmentMapper.Id                        = shipment.ID.GetValueOrDefault();
            shipmentMapper.RowNumber                 = shipment.RowNumber?.Value;
            shipmentMapper.Note                      = shipment.Note;
            shipmentMapper.CustomerId.Value          = shipment.CustomerID?.Value;
            shipmentMapper.ToWarehouseId.Value       = shipment.ToWarehouseID?.Value;
            shipmentMapper.ShipmentDate.Value        = shipment.ShipmentDate?.Value;
            shipmentMapper.ShipmentNbr.Value         = shipment.ShipmentNbr?.Value;
            shipmentMapper.WarehouseId.Value         = shipment.WarehouseID?.Value;
            shipmentMapper.Status.Value              = shipment.Status?.Value;
            shipmentMapper.ShipVia.Value             = shipment.ShipVia?.Value;
            shipmentMapper.Hold.Value                = shipment.Hold?.Value;
            shipmentMapper.Operation.Value           = shipment.Operation?.Value;
            shipmentMapper.Type.Value                = shipment.Type?.Value;
            shipmentMapper.Workgroup.Value           = shipment.Workgroup?.Value;
            shipmentMapper.ShippedQuantity.Value     = shipment.ShippedQuantity?.Value;
            shipmentMapper.ResidentialDelivery.Value = shipment.ResidentialDelivery?.Value;
            shipmentMapper.SaturdayDelivery.Value    = shipment.SaturdayDelivery?.Value;
            shipmentMapper.UseCustomersAccount.Value = shipment.UseCustomersAccount?.Value;
            shipmentMapper.OverrideAddress.Value     = shipment.OverrideAddress?.Value;
            shipmentMapper.OverrideContact.Value     = shipment.OverrideContact?.Value;
            //Shipment->Contact
            shipmentMapper.Contact.Id                = shipment.Contact?.ID;
            shipmentMapper.Contact.Note              = shipment.Contact?.Note;
            shipmentMapper.Contact.RowNumber         = shipment.Contact?.RowNumber?.Value;
            shipmentMapper.Contact.ContactId.Value   = shipment.Contact?.ContactID?.Value;
            shipmentMapper.Contact.DisplayName.Value = shipment.Contact?.DisplayName?.Value;
            shipmentMapper.Contact.Position.Value    = shipment.Contact?.Position?.Value;
            shipmentMapper.Contact.Email.Value       = shipment.Contact?.Email?.Value;
            shipmentMapper.Contact.Phone1.Value      = shipment.Contact?.Phone1?.Value;
            shipmentMapper.Contact.Fax.Value         = shipment.Contact?.Fax?.Value;
            shipmentMapper.Contact.Phone2.Value      = shipment.Contact?.Phone2?.Value;
            shipmentMapper.Contact.Web.Value         = shipment.Contact?.Web?.Value;
            shipmentMapper.Contact.FirstName.Value   = shipment.Contact?.FirstName?.Value;
            shipmentMapper.Contact.MiddleName.Value  = shipment.Contact?.MiddleName?.Value;
            shipmentMapper.Contact.LastName.Value    = shipment.Contact?.LastName?.Value;
            shipmentMapper.Contact.Title.Value       = shipment.Contact?.Title?.Value;
            shipmentMapper.Contact.Phone1Type.Value  = shipment.Contact?.Phone1Type?.Value;
            shipmentMapper.Contact.Phone2Type.Value  = shipment.Contact?.Phone2Type?.Value;
            //Shipment->Contact->Address
            shipmentMapper.Contact.Address.Id                 = shipment.Contact?.Address?.ID;
            shipmentMapper.Contact.Address.Note               = shipment.Contact?.Address?.Note;
            shipmentMapper.Contact.Address.RowNumber          = shipment.Contact?.Address?.RowNumber?.Value;
            shipmentMapper.Contact.Address.AddressLine1.Value = shipment.Contact?.Address?.AddressLine1?.Value;
            shipmentMapper.Contact.Address.AddressLine2.Value = shipment.Contact?.Address?.AddressLine2?.Value;
            shipmentMapper.Contact.Address.City.Value         = shipment.Contact?.Address?.City?.Value;
            shipmentMapper.Contact.Address.Country.Value      = shipment.Contact?.Address?.Country?.Value;
            shipmentMapper.Contact.Address.CountryName.Value  = UppercaseWords(shipmentMapper.Contact.Address.Country.Value.GetConuntryName().ToLower());
            shipmentMapper.Contact.Address.PostalCode.Value   = shipment.Contact?.Address?.PostalCode?.Value;
            shipmentMapper.Contact.Address.State.Value        = shipment.Contact?.Address?.State?.Value;

            //Shipment->Packages
            foreach (var package in shipment.Packages)
            {
                var shipmentPackage = new ShipmentPackage
                {
                    Id                  = package.ID.GetValueOrDefault(),
                    RowNumber           = package.RowNumber?.Value,
                    Note                = package.Note,
                    BoxId               = { Value = package.BoxID?.Value },
                    CodAmount           = { Value = package.CODAmount?.Value },
                    Confirmed           = { Value = package.Confirmed?.Value },
                    CustomRefNbr1       = { Value = package.CustomRefNbr1?.Value },
                    CustomRefNbr2       = { Value = package.CustomRefNbr2?.Value },
                    DeclaredValue       = { Value = package.DeclaredValue?.Value },
                    Description         = { Value = package.Description?.Value },
                    Type                = { Value = package.Type?.Value },
                    TrackingNumber      = { Value = package.TrackingNumber?.Value },
                    Weight              = { Value = package.Weight?.Value },
                    Uom                 = { Value = package.UOM?.Value },
                    PackageWeight       = { Value = package.Weight?.Value.ToString() },
                    PackageRowNumberOne = { Value = shipment.ShipmentNbr?.Value },
                    PackageRowNumberTwo = { Value = package.RowNumber?.Value.ToString() }
                };

                decimal weight;
                if (decimal.TryParse(shipmentPackage.PackageWeight.Value, out weight))
                {
                    shipmentPackage.PackageFormattedWeight.Value = decimal.Round(weight, 1).ToString(CultureInfo.CurrentCulture);
                }

                shipmentMapper.Packages.Add(shipmentPackage);
            }


            //Shipment->Details
            foreach (var detail in shipment.Details)
            {
                var shipmentDetail = new ShipmentDetail
                {
                    Id             = detail.ID.GetValueOrDefault(),
                    RowNumber      = detail.RowNumber?.Value,
                    Note           = detail.Note,
                    InventoryId    = { Value = detail.InventoryID?.Value },
                    LineNbr        = { Value = detail.LineNbr?.Value },
                    LocationId     = { Value = detail.LocationID?.Value },
                    OpenQty        = { Value = detail.OpenQty?.Value },
                    OrderLineNbr   = { Value = detail.OrderLineNbr?.Value },
                    OrderNbr       = { Value = detail.OrderNbr?.Value },
                    OrderedQty     = { Value = detail.OrderedQty?.Value },
                    ReasonCode     = { Value = detail.ReasonCode?.Value },
                    ShippedQty     = { Value = detail.ShippedQty?.Value },
                    WarehouseId    = { Value = detail.WarehouseID?.Value },
                    Description    = { Value = detail.Description?.Value },
                    Uom            = { Value = detail.UOM?.Value },
                    OrderType      = { Value = detail.OrderType?.Value },
                    ExpirationDate = { Value = detail.ExpirationDate?.Value },
                    FreeItem       = { Value = detail.FreeItem?.Value },
                    LotSerialNbr   = { Value = detail.LotSerialNbr?.Value }
                };


                foreach (var allocation in detail.Allocations)
                {
                    var shipmentAllocation = new ShipmentDetailAllocation
                    {
                        Id             = allocation.ID.GetValueOrDefault(),
                        RowNumber      = allocation.RowNumber?.Value,
                        Note           = allocation.Note,
                        LocationId     = { Value = allocation.LocationID?.Value },
                        LotSerialNbr   = { Value = allocation.LotSerialNbr?.Value },
                        Qty            = { Value = allocation.Qty?.Value },
                        Uom            = { Value = allocation.UOM?.Value },
                        ExpirationDate = { Value = allocation.ExpirationDate?.Value },
                        Description    = { Value = allocation.Description?.Value }
                    };

                    shipmentDetail.Allocations.Add(shipmentAllocation);
                }

                shipmentMapper.Details.Add(shipmentDetail);
            }

            return(shipmentMapper);
        }
Example #3
0
 public static ShipmentMapper MapShipment(this ShipmentMapper shipmentMapper, Shipment shipment)
 {
     return(shipmentMapper.MapShipmentMapperToShipment(shipment));
 }