コード例 #1
0
		public static ShipmentItemEntity ToDataModel(this ShipmentItem shipmentItem, ShoppingCartEntity cartEntity, PrimaryKeyResolvingMap pkMap)
		{
			if (shipmentItem == null)
				throw new ArgumentNullException("shipmentItem");

			var retVal = new ShipmentItemEntity();
            pkMap.AddPair(shipmentItem, retVal);
            retVal.InjectFrom(shipmentItem);

            //Try to find cart line item by shipment item
            if(!String.IsNullOrEmpty(shipmentItem.LineItemId))
            {
                retVal.LineItem = cartEntity.Items.FirstOrDefault(x => x.Id == shipmentItem.LineItemId);
            }
            if(retVal.LineItem == null && shipmentItem.LineItem != null)
            {
                retVal.LineItem = cartEntity.Items.FirstOrDefault(x => x.Id == shipmentItem.LineItem.Id);
            }
            if (retVal.LineItem == null && shipmentItem.LineItem != null)
            {
                retVal.LineItem = cartEntity.Items.FirstOrDefault(x => x.ProductId == shipmentItem.LineItem.ProductId);
            }
            if(retVal.LineItem != null && !String.IsNullOrEmpty(retVal.LineItem.Id))
            {
                retVal.LineItemId = retVal.LineItem.Id;
                retVal.LineItem = null;
            }
         
			return retVal;
		}
コード例 #2
0
		/// <summary>
		/// Patch CatalogBase type
		/// </summary>
		/// <param name="source"></param>
		/// <param name="target"></param>
		public static void Patch(this ShipmentItemEntity source, ShipmentItemEntity target)
		{
			if (target == null)
				throw new ArgumentNullException("target");


			var patchInjectionPolicy = new PatchInjection<ShipmentItemEntity>(x => x.BarCode, x => x.ShipmentId, x=>x.Quantity);
			target.InjectFrom(patchInjectionPolicy, source);
		}
コード例 #3
0
        /// <summary>
        /// Patch CatalogBase type
        /// </summary>
        /// <param name="target"></param>
        public virtual void Patch(ShipmentItemEntity target)
        {
            if (target == null)
            {
                throw new ArgumentNullException(nameof(target));
            }

            target.BarCode  = BarCode;
            target.Quantity = Quantity;
        }