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); }
public IHttpActionResult GetNewShipment(string id) { coreModel.Shipment retVal = null; var order = _customerOrderService.GetById(id, coreModel.CustomerOrderResponseGroup.Full); if (order != null) { retVal = new coreModel.Shipment { Currency = order.Currency }; retVal.Number = _uniqueNumberGenerator.GenerateNumber("SH{0:yyMMdd}-{1:D5}"); //Detect not whole shipped items //TODO: LineItem partial shipping var shippedLineItemIds = order.Shipments.SelectMany(x => x.Items).Select(x => x.LineItemId); //TODO Add check for digital products (don't add to shipment) retVal.Items = order.Items.Where(x => !shippedLineItemIds.Contains(x.Id)) .Select(x => new coreModel.ShipmentItem(x)).ToList(); return(Ok(retVal.ToWebModel())); } return(NotFound()); }
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.ShippingMethod != null) { retVal.ShipmentMethodCode = shipment.ShippingMethod.Code; retVal.ShipmentMethodOption = shipment.ShippingMethod.OptionName; } 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; }
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); }
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); }
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); }
public IHttpActionResult GetNewShipment(string id) { coreModel.Shipment retVal = null; var order = _customerOrderService.GetById(id, coreModel.CustomerOrderResponseGroup.Full); if (order != null) { retVal = new coreModel.Shipment { Currency = order.Currency }; retVal.Number = _operationNumberGenerator.GenerateNumber(retVal); //distribute not shipped items var shippedItems = order.Shipments.SelectMany(x => x.Items).ToArray(); retVal.Items = order.Items.Where(x => !shippedItems.Any(y => y.Id == x.Id)).ToList(); return(Ok(retVal.ToWebModel())); } return(NotFound()); }
private static CustomerOrder GetTestOrder(string id) { var order = new CustomerOrder { Id = id, Currency = "USD", CustomerId = "Test Customer", EmployeeId = "employee", StoreId = "test store", CreatedDate = DateTime.Now, Addresses = new[] { new Address { AddressType = AddressType.Shipping, Phone = "+68787687", PostalCode = "19142", CountryCode = "US", CountryName = "United states", Email = "*****@*****.**", FirstName = "first name", LastName = "last name", Line1 = "6025 Greenway Ave", City = "Philadelphia", RegionId = "PA", RegionName = "Pennsylvania", Organization = "org1" } }.ToList(), Discount = new Discount { PromotionId = "testPromotion", Currency = "USD", DiscountAmount = 12, Coupon = new Coupon { Code = "ssss" } } }; var item1 = new LineItem { Id = Guid.NewGuid().ToString(), BasePrice = 10, Price = 20, ProductId = "shoes", CatalogId = "catalog", Currency = "USD", CategoryId = "category", Name = "shoes", Quantity = 2, ShippingMethodCode = "EMS", Discount = new Discount { PromotionId = "itemPromotion", Currency = "USD", DiscountAmount = 12, Coupon = new Coupon { Code = "ssss" } } }; var item2 = new LineItem { Id = Guid.NewGuid().ToString(), BasePrice = 100, Price = 100, ProductId = "t-shirt", CatalogId = "catalog", CategoryId = "category", Currency = "USD", Name = "t-shirt", Quantity = 2, ShippingMethodCode = "EMS", Discount = new Discount { PromotionId = "testPromotion", Currency = "USD", DiscountAmount = 12, Coupon = new Coupon { Code = "ssss" } } }; order.Items = new List <LineItem>(); order.Items.Add(item1); order.Items.Add(item2); var shipment = new Shipment { Id = Guid.NewGuid().ToString(), Currency = "USD", DeliveryAddress = new 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 Discount { PromotionId = "testPromotion", Currency = "USD", DiscountAmount = 12, Coupon = new Coupon { Code = "ssss" } } }; order.Shipments = new List <Shipment>(); order.Shipments.Add(shipment); var payment = new PaymentIn { Id = Guid.NewGuid().ToString(), GatewayCode = "PayPal", Currency = "USD", Sum = 10, CustomerId = "et", IsApproved = false }; order.InPayments = new List <PaymentIn> { payment }; return(order); }
public IHttpActionResult GetNewShipment(string id) { coreModel.Shipment retVal = null; var order = _customerOrderService.GetById(id, coreModel.CustomerOrderResponseGroup.Full); if (order != null) { retVal = new coreModel.Shipment { Currency = order.Currency }; retVal.Number = _operationNumberGenerator.GenerateNumber(retVal); //distribute not shipped items var shippedItems = order.Shipments.SelectMany(x => x.Items).ToArray(); retVal.Items = order.Items.Where(x => !shippedItems.Any(y => y.Id == x.Id)).ToList(); return Ok(retVal.ToWebModel()); } return NotFound(); }
private static CustomerOrder GetTestOrder(string id) { var order = new CustomerOrder { Id = id, Currency = CurrencyCodes.USD, CustomerId = "Test Customer", EmployeeId = "employee", StoreId = "test store", CreatedDate = DateTime.Now, Addresses = new [] { new Address { AddressType = AddressType.Shipping, Phone = "+68787687", PostalCode = "60602", CountryCode = "US", CountryName = "United states", Email = "*****@*****.**", FirstName = "first name", LastName = "last name", Line1 = "45 Fremont Street", City = "Los Angeles", RegionId = "CA", Organization = "org1" } }.ToList(), Discount = new Discount { PromotionId = "testPromotion", Currency = CurrencyCodes.USD, DiscountAmount = 12, Coupon = new Coupon { Code = "ssss" } } }; var item1 = new LineItem { BasePrice = 10, Price = 20, ProductId = "shoes", CatalogId = "catalog", Currency = CurrencyCodes.USD, CategoryId = "category", Name = "shoes", Quantity = 2, ShippingMethodCode = "EMS", Discount = new Discount { PromotionId = "itemPromotion", Currency = CurrencyCodes.USD, DiscountAmount = 12, Coupon = new Coupon { Code = "ssss" } } }; var item2 = new LineItem { BasePrice = 100, Price = 100, ProductId = "t-shirt", CatalogId = "catalog", CategoryId = "category", Currency = CurrencyCodes.USD, Name = "t-shirt", Quantity = 2, ShippingMethodCode = "EMS", Discount = new Discount { PromotionId = "testPromotion", Currency = CurrencyCodes.USD, DiscountAmount = 12, Coupon = new Coupon { Code = "ssss" } } }; order.Items = new List<LineItem>(); order.Items.Add(item1); order.Items.Add(item2); var shipment = new Shipment { Currency = CurrencyCodes.USD, DeliveryAddress = new 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 Discount { PromotionId = "testPromotion", Currency = CurrencyCodes.USD, DiscountAmount = 12, Coupon = new Coupon { Code = "ssss" } } }; order.Shipments = new List<Shipment>(); order.Shipments.Add(shipment); var payment = new PaymentIn { GatewayCode = "PayPal", Currency = CurrencyCodes.USD, Sum = 10, CustomerId = "et" }; order.InPayments = new List<PaymentIn> { payment }; return order; }
public IHttpActionResult GetNewShipment(string id) { coreModel.Shipment retVal = null; var order = _customerOrderService.GetById(id, coreModel.CustomerOrderResponseGroup.Full); if (order != null) { retVal = new coreModel.Shipment { Currency = order.Currency }; retVal.Number = _uniqueNumberGenerator.GenerateNumber("SH{0:yyMMdd}-{1:D5}"); //Detect not whole shipped items //TODO: LineItem partial shipping var shippedLineItemIds = order.Shipments.SelectMany(x => x.Items).Select(x=>x.LineItemId); //TODO Add check for digital products (don't add to shipment) retVal.Items = order.Items.Where(x => !shippedLineItemIds.Contains(x.Id)) .Select(x => new coreModel.ShipmentItem(x)).ToList(); return Ok(retVal.ToWebModel()); } return NotFound(); }