public IHttpActionResult Update(webModel.CustomerOrder order) { var coreOrder = order.ToCoreModel(); _customerOrderService.Update(new coreModel.CustomerOrder[] { coreOrder }); return(StatusCode(HttpStatusCode.NoContent)); }
public static webModel.CustomerOrder ToWebModel(this coreModel.CustomerOrder customerOrder) { var retVal = new webModel.CustomerOrder(); retVal.InjectFrom(customerOrder); if (customerOrder.Discount != null) { retVal.Discount = customerOrder.Discount.ToWebModel(); } if (customerOrder.Shipments != null) retVal.Shipments = customerOrder.Shipments.Select(x => x.ToWebModel()).ToList(); if (customerOrder.InPayments != null) retVal.InPayments = customerOrder.InPayments.Select(x => x.ToWebModel()).ToList(); if (customerOrder.Items != null) retVal.Items = customerOrder.Items.Select(x => x.ToWebModel()).ToList(); if (customerOrder.Addresses != null) retVal.Addresses = customerOrder.Addresses.Select(x => x.ToWebModel()).ToList(); retVal.ChildrenOperations = customerOrder.GetFlatObjectsListWithInterface<coreModel.IOperation>().Except(new[] { customerOrder }).Select(x => x.ToWebModel()).ToList(); retVal.TaxDetails = customerOrder.TaxDetails; if (customerOrder.DynamicProperties != null) retVal.DynamicProperties = customerOrder.DynamicProperties; return retVal; }
public static coreModel.CustomerOrder ToCoreModel(this webModel.CustomerOrder customerOrder) { var retVal = new coreModel.CustomerOrder(); retVal.InjectFrom(customerOrder); retVal.Currency = customerOrder.Currency; if (customerOrder.Properties != null) { retVal.Properties = customerOrder.Properties.Select(x => x.ToCoreModel()).ToList(); } if (customerOrder.Items != null) { retVal.Items = customerOrder.Items.Select(x => x.ToCoreModel()).ToList(); } if (customerOrder.Addresses != null) { retVal.Addresses = customerOrder.Addresses.Select(x => x.ToCoreModel()).ToList(); } if (customerOrder.Shipments != null) { retVal.Shipments = customerOrder.Shipments.Select(x => x.ToCoreModel()).ToList(); } if (customerOrder.InPayments != null) { retVal.InPayments = customerOrder.InPayments.Select(x => x.ToCoreModel()).ToList(); } if (customerOrder.Discount != null) { retVal.Discount = customerOrder.Discount.ToCoreModel(); } retVal.TaxDetails = customerOrder.TaxDetails; return(retVal); }
public void FulfilOrderWithSingleShipmentAndPartialUpdate() { var result = _controller.GetById("order1") as OkNegotiatedContentResult <webModel.CustomerOrder>; var testOrder = result.Content; var partialChangeOrder = new webModel.CustomerOrder { Id = testOrder.Id, Shipments = testOrder.Shipments }; var shipment = partialChangeOrder.Shipments.FirstOrDefault(); shipment.Items = new List <webModel.ShipmentItem>(); foreach (var item in testOrder.Items) { var shipmentItem = new webModel.ShipmentItem { LineItemId = item.Id, Quantity = item.Quantity, }; item.Id = null; shipment.Items.Add(shipmentItem); } shipment.IsApproved = true; _controller.Update(partialChangeOrder); }
public static webModel.CustomerOrder ToWebModel(this coreModel.CustomerOrder customerOrder) { var retVal = new webModel.CustomerOrder(); retVal.InjectFrom(customerOrder); if (customerOrder.Discount != null) { retVal.Discount = customerOrder.Discount.ToWebModel(); retVal.DiscountAmount = customerOrder.Discount.DiscountAmount; } if (customerOrder.Shipments != null) retVal.Shipments = customerOrder.Shipments.Select(x => x.ToWebModel()).ToList(); if (customerOrder.InPayments != null) retVal.InPayments = customerOrder.InPayments.Select(x => x.ToWebModel()).ToList(); if (customerOrder.Items != null) retVal.Items = customerOrder.Items.Select(x => x.ToWebModel()).ToList(); if (customerOrder.Addresses != null) retVal.Addresses = customerOrder.Addresses.Select(x => x.ToWebModel()).ToList(); retVal.ChildrenOperations = customerOrder.ChildrenOperations.Select(x => x.ToWebModel()).ToList(); retVal.TaxDetails = customerOrder.TaxDetails; if (customerOrder.DynamicProperties != null) retVal.DynamicProperties = customerOrder.DynamicProperties; return retVal; }
public IHttpActionResult Update(webModel.CustomerOrder customerOrder) { var coreOrder = customerOrder.ToCoreModel(); //Check scope bound permission var scopes = _permissionScopeService.GetObjectPermissionScopeStrings(coreOrder).ToArray(); if (!_securityService.UserHasAnyPermission(User.Identity.Name, scopes, OrderPredefinedPermissions.Read)) { throw new HttpResponseException(HttpStatusCode.Unauthorized); } _customerOrderService.Update(new coreModel.CustomerOrder[] { coreOrder }); return(StatusCode(HttpStatusCode.NoContent)); }
public static webModel.CustomerOrder ToWebModel(this coreModel.CustomerOrder customerOrder) { var retVal = new webModel.CustomerOrder(); retVal.InjectFrom(customerOrder); //TODO: resolve id to names retVal.Customer = retVal.CustomerId; retVal.StoreId = retVal.StoreId; retVal.OrganizationId = retVal.OrganizationId; retVal.EmployeeId = retVal.EmployeeId; if (customerOrder.Discount != null) { retVal.Discount = customerOrder.Discount.ToWebModel(); retVal.DiscountAmount = customerOrder.Discount.DiscountAmount; } if (customerOrder.Properties != null) { retVal.Properties = customerOrder.Properties.Select(x => x.ToWebModel()).ToList(); } if (customerOrder.Shipments != null) { retVal.Shipments = customerOrder.Shipments.Select(x => x.ToWebModel()).ToList(); } if (customerOrder.InPayments != null) { retVal.InPayments = customerOrder.InPayments.Select(x => x.ToWebModel()).ToList(); } if (customerOrder.Items != null) { retVal.Items = customerOrder.Items.Select(x => x.ToWebModel()).ToList(); } if (customerOrder.Addresses != null) { retVal.Addresses = customerOrder.Addresses.Select(x => x.ToWebModel()).ToList(); } retVal.ChildrenOperations = customerOrder.ChildrenOperations.Select(x => x.ToWebModel()).ToList(); retVal.TaxDetails = customerOrder.TaxDetails; return(retVal); }
public static webModel.CustomerOrder ToWebModel(this coreModel.CustomerOrder customerOrder) { var retVal = new webModel.CustomerOrder(); retVal.InjectFrom(customerOrder); if (customerOrder.Discount != null) { retVal.Discount = customerOrder.Discount.ToWebModel(); retVal.DiscountAmount = customerOrder.Discount.DiscountAmount; } if (customerOrder.Shipments != null) { retVal.Shipments = customerOrder.Shipments.Select(x => x.ToWebModel()).ToList(); } if (customerOrder.InPayments != null) { retVal.InPayments = customerOrder.InPayments.Select(x => x.ToWebModel()).ToList(); } if (customerOrder.Items != null) { retVal.Items = customerOrder.Items.Select(x => x.ToWebModel()).ToList(); } if (customerOrder.Addresses != null) { retVal.Addresses = customerOrder.Addresses.Select(x => x.ToWebModel()).ToList(); } retVal.ChildrenOperations = customerOrder.GetFlatObjectsListWithInterface <coreModel.IOperation>().Except(new[] { customerOrder }).Select(x => x.ToWebModel()).ToList(); retVal.TaxDetails = customerOrder.TaxDetails; if (customerOrder.DynamicProperties != null) { retVal.DynamicProperties = customerOrder.DynamicProperties; } return(retVal); }
public static webModel.CustomerOrder ToWebModel(this coreModel.CustomerOrder customerOrder) { var retVal = new webModel.CustomerOrder(); retVal.InjectFrom(customerOrder); //TODO: resolve id to names retVal.Customer = retVal.CustomerId; retVal.StoreId = retVal.StoreId; retVal.OrganizationId = retVal.OrganizationId; retVal.EmployeeId = retVal.EmployeeId; if (customerOrder.Discount != null) { retVal.Discount = customerOrder.Discount.ToWebModel(); retVal.DiscountAmount = customerOrder.Discount.DiscountAmount; } if (customerOrder.Properties != null) retVal.Properties = customerOrder.Properties.Select(x => x.ToWebModel()).ToList(); if (customerOrder.Shipments != null) retVal.Shipments = customerOrder.Shipments.Select(x => x.ToWebModel()).ToList(); if (customerOrder.InPayments != null) retVal.InPayments = customerOrder.InPayments.Select(x => x.ToWebModel()).ToList(); if (customerOrder.Items != null) retVal.Items = customerOrder.Items.Select(x => x.ToWebModel()).ToList(); if (customerOrder.Addresses != null) retVal.Addresses = customerOrder.Addresses.Select(x => x.ToWebModel()).ToList(); retVal.ChildrenOperations = customerOrder.ChildrenOperations.Select(x => x.ToWebModel()).ToList(); retVal.TaxDetails = customerOrder.TaxDetails; return retVal; }
public IHttpActionResult CreateOrder(webModel.CustomerOrder customerOrder) { var retVal = _customerOrderService.Create(customerOrder.ToCoreModel()); return(Ok(retVal.ToWebModel())); }
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); }
public void FulfilOrderWithSingleShipmentAndPartialUpdate() { var result = _controller.GetById("order1") as OkNegotiatedContentResult<webModel.CustomerOrder>; var testOrder = result.Content; var partialChangeOrder = new webModel.CustomerOrder { Id = testOrder.Id, Shipments = testOrder.Shipments }; var shipment = partialChangeOrder.Shipments.FirstOrDefault(); shipment.Items = new List<webModel.ShipmentItem>(); foreach (var item in testOrder.Items) { var shipmentItem = new webModel.ShipmentItem { LineItemId = item.Id, Quantity = item.Quantity, }; item.Id = null; shipment.Items.Add(shipmentItem); } shipment.IsApproved = true; _controller.Update(partialChangeOrder); }
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; }