public static webModel.Shipment ToWebModel(this coreModel.Shipment shipment)
		{
			var retVal = new webModel.Shipment();
			retVal.InjectFrom(shipment);


			if (shipment.DeliveryAddress != null)
				retVal.DeliveryAddress = shipment.DeliveryAddress.ToWebModel();

			if (shipment.InPayments != null)
				retVal.InPayments = shipment.InPayments.Select(x => x.ToWebModel()).ToList();

			if(shipment.Items != null)
				retVal.Items = shipment.Items.Select(x => x.ToWebModel()).ToList();

			if (shipment.Packages != null)
				retVal.Packages = shipment.Packages.Select(x => x.ToWebModel()).ToList();

			if (shipment.Discount != null)
			{
				retVal.Discount = shipment.Discount.ToWebModel();
				retVal.DiscountAmount = shipment.Discount.DiscountAmount;
			}

			retVal.ChildrenOperations = shipment.ChildrenOperations.Select(x => x.ToWebModel()).ToList();
			retVal.TaxDetails = shipment.TaxDetails;

			if (shipment.DynamicProperties != null)
				retVal.DynamicProperties = shipment.DynamicProperties;

			return retVal;
		}
        public void FulfilOrderWithMultipleShipment()
        {
            var result    = _controller.GetById("d2a855c7-dc88-44b3-ab4e-4dba3fc89057") as OkNegotiatedContentResult <webModel.CustomerOrder>;
            var testOrder = result.Content;

            var newShipment = new webModel.Shipment
            {
                Id              = Guid.NewGuid().ToString(),
                Currency        = testOrder.Currency,
                DeliveryAddress = testOrder.Addresses.FirstOrDefault(),
                IsApproved      = true,
            };

            testOrder.IsApproved = true;

            testOrder.Shipments.Add(newShipment);
            //Aprove shipment
            foreach (var shipment in testOrder.Shipments)
            {
                shipment.IsApproved = true;
            }
            _controller.Update(testOrder);

            result    = _controller.GetById(testOrder.Id) as OkNegotiatedContentResult <webModel.CustomerOrder>;
            testOrder = result.Content;
        }
        public static coreModel.Shipment ToCoreModel(this webModel.Shipment shipment)
        {
            var retVal = new coreModel.Shipment();

            retVal.InjectFrom(shipment);


            if (shipment.DeliveryAddress != null)
            {
                retVal.DeliveryAddress = shipment.DeliveryAddress.ToCoreModel();
            }
            if (shipment.InPayments != null)
            {
                retVal.InPayments = shipment.InPayments.Select(x => x.ToCoreModel()).ToList();
            }
            if (shipment.Discount != null)
            {
                retVal.Discount = shipment.Discount.ToCoreModel();
            }
            if (shipment.Items != null)
            {
                retVal.Items = shipment.Items.Select(x => x.ToCoreModel()).ToList();
            }
            if (shipment.Packages != null)
            {
                retVal.Packages = shipment.Packages.Select(x => x.ToCoreModel()).ToList();
            }
            if (shipment.DynamicProperties != null)
            {
                retVal.DynamicProperties = shipment.DynamicProperties;
            }

            retVal.TaxDetails = shipment.TaxDetails;
            return(retVal);
        }
예제 #4
0
        public static webModel.Shipment ToWebModel(this coreModel.Shipment shipment)
        {
            var retVal = new webModel.Shipment();

            retVal.InjectFrom(shipment);


            if (shipment.DeliveryAddress != null)
            {
                retVal.DeliveryAddress = shipment.DeliveryAddress.ToWebModel();
            }

            if (shipment.InPayments != null)
            {
                retVal.InPayments = shipment.InPayments.Select(x => x.ToWebModel()).ToList();
            }

            if (shipment.Items != null)
            {
                retVal.Items = shipment.Items.Select(x => x.ToWebModel()).ToList();
            }

            if (shipment.Packages != null)
            {
                retVal.Packages = shipment.Packages.Select(x => x.ToWebModel()).ToList();
            }

            if (shipment.Discount != null)
            {
                retVal.Discount       = shipment.Discount.ToWebModel();
                retVal.DiscountAmount = shipment.Discount.DiscountAmount;
            }

            //Populate shipment method for shipment
            retVal.ShippingMethod                   = new webModel.ShippingMethod();
            retVal.ShippingMethod.Code              = shipment.ShipmentMethodCode;
            retVal.ShippingMethod.Description       = shipment.ShipmentMethodCode;
            retVal.ShippingMethod.OptionDescription = shipment.ShipmentMethodOption;
            retVal.ShippingMethod.OptionName        = shipment.ShipmentMethodOption;

            if (shipment.ShippingMethod != null)
            {
                retVal.ShippingMethod = shipment.ShippingMethod.ToWebModel();
            }

            retVal.ChildrenOperations = shipment.GetFlatObjectsListWithInterface <coreModel.IOperation>().Except(new[] { shipment }).Select(x => x.ToWebModel()).ToList();

            retVal.TaxDetails = shipment.TaxDetails;

            if (shipment.DynamicProperties != null)
            {
                retVal.DynamicProperties = shipment.DynamicProperties;
            }

            return(retVal);
        }
예제 #5
0
		public static webModel.Shipment ToWebModel(this coreModel.Shipment shipment)
		{
			var retVal = new webModel.Shipment();
			retVal.InjectFrom(shipment);


			if (shipment.DeliveryAddress != null)
				retVal.DeliveryAddress = shipment.DeliveryAddress.ToWebModel();

			if (shipment.InPayments != null)
				retVal.InPayments = shipment.InPayments.Select(x => x.ToWebModel()).ToList();

			if(shipment.Items != null)
				retVal.Items = shipment.Items.Select(x => x.ToWebModel()).ToList();

			if (shipment.Packages != null)
				retVal.Packages = shipment.Packages.Select(x => x.ToWebModel()).ToList();

			if (shipment.Discount != null)
			{
				retVal.Discount = shipment.Discount.ToWebModel();
				retVal.DiscountAmount = shipment.Discount.DiscountAmount;
			}

            //Populate shipment method for shipment
            retVal.ShippingMethod = new webModel.ShippingMethod();
            retVal.ShippingMethod.Code = shipment.ShipmentMethodCode;
            retVal.ShippingMethod.Description = shipment.ShipmentMethodCode;
            retVal.ShippingMethod.OptionDescription = shipment.ShipmentMethodOption;
            retVal.ShippingMethod.OptionName = shipment.ShipmentMethodOption;

            if (shipment.ShippingMethod != null)
            {
                retVal.ShippingMethod = shipment.ShippingMethod.ToWebModel();
            }

            retVal.ChildrenOperations = shipment.GetFlatObjectsListWithInterface<coreModel.IOperation>().Except(new[] { shipment }).Select(x => x.ToWebModel()).ToList();

			retVal.TaxDetails = shipment.TaxDetails;

			if (shipment.DynamicProperties != null)
				retVal.DynamicProperties = shipment.DynamicProperties;

			return retVal;
		}
예제 #6
0
        public static webModel.Shipment ToWebModel(this coreModel.Shipment shipment)
        {
            var retVal = new webModel.Shipment();

            retVal.InjectFrom(shipment);


            if (shipment.DeliveryAddress != null)
            {
                retVal.DeliveryAddress = shipment.DeliveryAddress.ToWebModel();
            }

            if (shipment.InPayments != null)
            {
                retVal.InPayments = shipment.InPayments.Select(x => x.ToWebModel()).ToList();
            }

            if (shipment.Items != null)
            {
                retVal.Items = shipment.Items.Select(x => x.ToWebModel()).ToList();
            }

            if (shipment.Packages != null)
            {
                retVal.Packages = shipment.Packages.Select(x => x.ToWebModel()).ToList();
            }

            if (shipment.Discount != null)
            {
                retVal.Discount       = shipment.Discount.ToWebModel();
                retVal.DiscountAmount = shipment.Discount.DiscountAmount;
            }

            retVal.ChildrenOperations = shipment.GetFlatObjectsListWithInterface <coreModel.IOperation>().Except(new[] { shipment }).Select(x => x.ToWebModel()).ToList();

            retVal.TaxDetails = shipment.TaxDetails;

            if (shipment.DynamicProperties != null)
            {
                retVal.DynamicProperties = shipment.DynamicProperties;
            }

            return(retVal);
        }
예제 #7
0
        public static webModel.Shipment ToWebModel(this coreModel.Shipment shipment)
        {
            var retVal = new webModel.Shipment();

            retVal.InjectFrom(shipment);

            retVal.Organization      = retVal.OrganizationId;
            retVal.FulfillmentCenter = retVal.FulfillmentCenterId;
            retVal.Employee          = retVal.EmployeeId;



            if (shipment.Properties != null)
            {
                retVal.Properties = shipment.Properties.Select(x => x.ToWebModel()).ToList();
            }

            if (shipment.DeliveryAddress != null)
            {
                retVal.DeliveryAddress = shipment.DeliveryAddress.ToWebModel();
            }

            if (shipment.InPayments != null)
            {
                retVal.InPayments = shipment.InPayments.Select(x => x.ToWebModel()).ToList();
            }

            if (shipment.Items != null)
            {
                retVal.Items = shipment.Items.Select(x => x.ToWebModel()).ToList();
            }

            if (shipment.Discount != null)
            {
                retVal.Discount       = shipment.Discount.ToWebModel();
                retVal.DiscountAmount = shipment.Discount.DiscountAmount;
            }

            retVal.ChildrenOperations = shipment.ChildrenOperations.Select(x => x.ToWebModel()).ToList();
            retVal.TaxDetails         = shipment.TaxDetails;
            return(retVal);
        }
        private static webModel.CustomerOrder GetTestOrder(string id)
        {
            var order = new webModel.CustomerOrder
            {
                Id         = id,
                Currency   = CurrencyCodes.USD,
                CustomerId = "vasja customer",
                EmployeeId = "employe",
                StoreId    = "test store",
                Addresses  = new webModel.Address[]
                {
                    new webModel.Address {
                        AddressType  = AddressType.Shipping,
                        City         = "london",
                        Phone        = "+68787687",
                        PostalCode   = "22222",
                        CountryCode  = "ENG",
                        CountryName  = "England",
                        Email        = "*****@*****.**",
                        FirstName    = "first name",
                        LastName     = "last name",
                        Line1        = "line 1",
                        Organization = "org1"
                    }
                }.ToList(),
                Discount = new webModel.Discount
                {
                    PromotionId    = "testPromotion",
                    Currency       = CurrencyCodes.USD,
                    DiscountAmount = 12,
                    Coupon         = new webModel.Coupon
                    {
                        Code = "ssss"
                    }
                }
            };
            var item1 = new webModel.LineItem
            {
                BasePrice              = 10,
                Price                  = 9,
                DisplayName            = "shoes",
                ProductId              = "shoes",
                CatalogId              = "catalog",
                Currency               = CurrencyCodes.USD,
                CategoryId             = "category",
                Name                   = "shoes",
                Quantity               = 2,
                FulfilmentLocationCode = "warehouse1",
                ShippingMethodCode     = "EMS",
                Discount               = new webModel.Discount
                {
                    PromotionId    = "itemPromotion",
                    Currency       = CurrencyCodes.USD,
                    DiscountAmount = 12,
                    Coupon         = new webModel.Coupon
                    {
                        Code = "ssss"
                    }
                }
            };
            var item2 = new webModel.LineItem
            {
                BasePrice              = 100,
                Price                  = 100,
                DisplayName            = "t-shirt",
                ProductId              = "t-shirt",
                CatalogId              = "catalog",
                CategoryId             = "category",
                Currency               = CurrencyCodes.USD,
                Name                   = "t-shirt",
                Quantity               = 2,
                FulfilmentLocationCode = "warehouse1",
                ShippingMethodCode     = "EMS",
                Discount               = new webModel.Discount
                {
                    PromotionId    = "testPromotion",
                    Currency       = CurrencyCodes.USD,
                    DiscountAmount = 12,
                    Coupon         = new webModel.Coupon
                    {
                        Code = "ssss"
                    }
                }
            };

            order.Items = new List <webModel.LineItem>();
            order.Items.Add(item1);
            order.Items.Add(item2);

            var shipment = new webModel.Shipment
            {
                Currency        = CurrencyCodes.USD,
                DeliveryAddress = new webModel.Address
                {
                    City         = "london",
                    CountryName  = "England",
                    Phone        = "+68787687",
                    PostalCode   = "2222",
                    CountryCode  = "ENG",
                    Email        = "*****@*****.**",
                    FirstName    = "first name",
                    LastName     = "last name",
                    Line1        = "line 1",
                    Organization = "org1"
                },
                Discount = new webModel.Discount
                {
                    PromotionId    = "testPromotion",
                    Currency       = CurrencyCodes.USD,
                    DiscountAmount = 12,
                    Coupon         = new webModel.Coupon
                    {
                        Code = "ssss"
                    }
                },
            };

            shipment.Items = new List <webModel.ShipmentItem>();
            shipment.Items.AddRange(order.Items.Select(x => new webModel.ShipmentItem {
                Quantity = x.Quantity, LineItem = x
            }));

            order.Shipments = new List <webModel.Shipment>();
            order.Shipments.Add(shipment);

            var payment = new webModel.PaymentIn
            {
                Currency   = CurrencyCodes.USD,
                Sum        = 10,
                CustomerId = "et"
            };

            order.InPayments = new List <webModel.PaymentIn>();
            order.InPayments.Add(payment);

            return(order);
        }
		private static webModel.CustomerOrder GetTestOrder(string id)
		{
			var order = new webModel.CustomerOrder
			{
				Id = id,
				Currency = CurrencyCodes.USD,
				CustomerId = "vasja customer",
				EmployeeId = "employe",
				StoreId = "test store",
				Addresses = new webModel.Address[]
				{
					new webModel.Address {	
					AddressType = coreModel.AddressType.Shipping, 
					City = "london",
					Phone = "+68787687",
					PostalCode = "22222",
					CountryCode = "ENG",
					CountryName = "England",
					Email = "*****@*****.**",
					FirstName = "first name",
					LastName = "last name",
					Line1 = "line 1",
					Organization = "org1"
					}
				}.ToList(),
				Discount = new webModel.Discount
				{
					PromotionId = "testPromotion",
					Currency = CurrencyCodes.USD,
					DiscountAmount = 12,
					Coupon = new webModel.Coupon
					{
						Code = "ssss"
					}
				}
			};
			var item1 = new webModel.LineItem
			{
				BasePrice = 10,
				Price = 9,
				DisplayName = "shoes",
				ProductId = "shoes",
				CatalogId = "catalog",
				Currency = CurrencyCodes.USD,
				CategoryId = "category",
				Name = "shoes",
				Quantity = 2,
				FulfilmentLocationCode = "warehouse1",
				ShippingMethodCode = "EMS",
				Discount = new webModel.Discount
				{
					PromotionId = "itemPromotion",
					Currency = CurrencyCodes.USD,
					DiscountAmount = 12,
					Coupon = new webModel.Coupon
					{
						Code = "ssss"
					}
				}
			};
			var item2 = new webModel.LineItem
			{
				BasePrice = 100,
				Price = 100,
				DisplayName = "t-shirt",
				ProductId = "t-shirt",
				CatalogId = "catalog",
				CategoryId = "category",
				Currency = CurrencyCodes.USD,
				Name = "t-shirt",
				Quantity = 2,
				FulfilmentLocationCode = "warehouse1",
				ShippingMethodCode = "EMS",
				Discount = new webModel.Discount
				{
					PromotionId = "testPromotion",
					Currency = CurrencyCodes.USD,
					DiscountAmount = 12,
					Coupon = new webModel.Coupon
					{
						Code = "ssss"
					}
				}
			};
			order.Items = new List<webModel.LineItem>();
			order.Items.Add(item1);
			order.Items.Add(item2);

			var shipment = new webModel.Shipment
			{
				Currency = CurrencyCodes.USD,
				DeliveryAddress = new webModel.Address
				{
					City = "london",
					CountryName = "England",
					Phone = "+68787687",
					PostalCode = "2222",
					CountryCode = "ENG",
					Email = "*****@*****.**",
					FirstName = "first name",
					LastName = "last name",
					Line1 = "line 1",
					Organization = "org1"
				},
				Discount = new webModel.Discount
				{
					PromotionId = "testPromotion",
					Currency = CurrencyCodes.USD,
					DiscountAmount = 12,
					Coupon = new webModel.Coupon
					{
						Code = "ssss"
					}
				},

			};

			shipment.Items = new List<webModel.ShipmentItem>();
			shipment.Items.AddRange(order.Items.Select(x=> new webModel.ShipmentItem { Quantity = x.Quantity, LineItem = x }));
			
			order.Shipments = new List<webModel.Shipment>();
			order.Shipments.Add(shipment);

			var payment = new webModel.PaymentIn
			{
				GatewayCode = "PayPal",
				Currency = CurrencyCodes.USD,
				Sum = 10,
				CustomerId = "et"
			};
			order.InPayments = new List<webModel.PaymentIn>();
			order.InPayments.Add(payment);

			return order;
		}
		public void FulfilOrderWithMultipleShipment()
		{
			var result = _controller.GetById("d2a855c7-dc88-44b3-ab4e-4dba3fc89057") as OkNegotiatedContentResult<webModel.CustomerOrder>;
			var testOrder = result.Content;

			var newShipment = new webModel.Shipment
			{
				Id = Guid.NewGuid().ToString(),
				Currency = testOrder.Currency,
				DeliveryAddress = testOrder.Addresses.FirstOrDefault(),
				IsApproved = true,
			
			};
			testOrder.IsApproved = true;

			testOrder.Shipments.Add(newShipment);
			//Aprove shipment
			foreach (var shipment in testOrder.Shipments)
			{
				shipment.IsApproved = true;
			}
			_controller.Update(testOrder);

			result = _controller.GetById(testOrder.Id) as OkNegotiatedContentResult<webModel.CustomerOrder>;
			testOrder = result.Content;
		}