public override CustomerOrderEntity[] GetCustomerOrdersByIds(string[] ids, CustomerOrderResponseGroup responseGroup) { var retVal = base.GetCustomerOrdersByIds(ids, responseGroup); var invoices = Invoices.Where(x => ids.Contains(x.CustomerOrder2Id)).ToArray(); return(retVal); }
public CustomerOrderEntity GetCustomerOrderById(string id, CustomerOrderResponseGroup responseGroup) { var query = CustomerOrders.Where(x => x.Id == id) .Include(x => x.Discounts) .Include(x => x.TaxDetails); if ((responseGroup & CustomerOrderResponseGroup.WithAddresses) == CustomerOrderResponseGroup.WithAddresses) { var addresses = Addresses.Where(x => x.CustomerOrderId == id).ToArray(); } if ((responseGroup & CustomerOrderResponseGroup.WithInPayments) == CustomerOrderResponseGroup.WithInPayments) { var inPayments = InPayments.Where(x => x.CustomerOrderId == id).ToArray(); var paymentsIds = inPayments.Select(x => x.Id).ToArray(); var paymentAddresses = Addresses.Where(x => paymentsIds.Contains(x.PaymentInId)).ToArray(); } if ((responseGroup & CustomerOrderResponseGroup.WithItems) == CustomerOrderResponseGroup.WithItems) { var lineItems = LineItems.Include(x => x.TaxDetails) .Include(x => x.Discounts) .Where(x => x.CustomerOrderId == id).ToArray(); } if ((responseGroup & CustomerOrderResponseGroup.WithShipments) == CustomerOrderResponseGroup.WithShipments) { var shipments = Shipments.Include(x => x.TaxDetails) .Include(x => x.Discounts) .Include(x => x.Items) .Include(x => x.Packages.Select(y => y.Items)) .Where(x => x.CustomerOrderId == id).ToArray(); var shipmentIds = shipments.Select(x => x.Id).ToArray(); var addresses = Addresses.Where(x => shipmentIds.Contains(x.ShipmentId)).ToArray(); } return(query.FirstOrDefault()); }
public static string ApplyResponseGroupFiltering(Permission[] permissions, string respGroup) { var result = respGroup; var needRestrict = permissions.Any() && !permissions.Any(x => x.Id == OrderPredefinedPermissions.ReadPrices); if (needRestrict && string.IsNullOrWhiteSpace(respGroup)) { const CustomerOrderResponseGroup val = CustomerOrderResponseGroup.Full & ~CustomerOrderResponseGroup.WithPrices; result = val.ToString(); } else if (needRestrict) { var items = respGroup.Split(',').Select(x => x.Trim()).ToList(); items.Remove(CustomerOrderResponseGroup.WithPrices.ToString()); result = string.Join(",", items); } if (needRestrict && string.IsNullOrEmpty(result)) { result = CustomerOrderResponseGroup.Default.ToString(); } return(result); }
public virtual CustomerOrder GetById(string orderId, CustomerOrderResponseGroup respGroup) { CustomerOrder retVal = null; using (var repository = _repositoryFactory()) { var orderEntity = repository.GetCustomerOrderById(orderId, respGroup); if (orderEntity != null) { retVal = orderEntity.ToCoreModel(_shippingMethodsService.GetAllShippingMethods(), _paymentMethodsService.GetAllPaymentMethods()); if ((respGroup & CustomerOrderResponseGroup.WithProducts) == CustomerOrderResponseGroup.WithProducts) { var productIds = retVal.Items.Select(x => x.ProductId).ToArray(); var products = _productService.GetByIds(productIds, Domain.Catalog.Model.ItemResponseGroup.ItemInfo); foreach (var lineItem in retVal.Items) { var product = products.FirstOrDefault(x => x.Id == lineItem.ProductId); if (product != null) { lineItem.Product = product; } } } } } _dynamicPropertyService.LoadDynamicPropertyValues(retVal); _eventPublisher.Publish(new OrderChangeEvent(EntryState.Unchanged, retVal, retVal)); return(retVal); }
public virtual CustomerOrder GetById(string orderId, CustomerOrderResponseGroup respGroup) { CustomerOrder retVal = null; using (var repository = _repositoryFactory()) { var orderEntity = repository.GetCustomerOrderById(orderId, respGroup); if (orderEntity != null) { retVal = orderEntity.ToCoreModel(_shippingMethodsService.GetAllShippingMethods(), _paymentMethodsService.GetAllPaymentMethods()); if ((respGroup & CustomerOrderResponseGroup.WithProducts) == CustomerOrderResponseGroup.WithProducts) { var productIds = retVal.Items.Select(x => x.ProductId).ToArray(); var products = _productService.GetByIds(productIds, Domain.Catalog.Model.ItemResponseGroup.ItemInfo); foreach (var lineItem in retVal.Items) { var product = products.FirstOrDefault(x => x.Id == lineItem.ProductId); if (product != null) { lineItem.Product = product; } } } } } _dynamicPropertyService.LoadDynamicPropertyValues(retVal); _eventPublisher.Publish(new OrderChangeEvent(EntryState.Unchanged, retVal, retVal)); return retVal; }
public CustomerOrderEntity GetCustomerOrderById(string id, CustomerOrderResponseGroup responseGroup) { var query = CustomerOrders.Where(x => x.Id == id) .Include(x => x.Discounts) .Include(x => x.Properties) .Include(x => x.TaxDetails); if ((responseGroup & CustomerOrderResponseGroup.WithAddresses) == CustomerOrderResponseGroup.WithAddresses) { query = query.Include(x => x.Addresses); } if ((responseGroup & CustomerOrderResponseGroup.WithInPayments) == CustomerOrderResponseGroup.WithInPayments) { query = query.Include(x => x.InPayments.Select(y => y.Addresses)) .Include(x => x.InPayments.Select(y => y.Properties)); } if ((responseGroup & CustomerOrderResponseGroup.WithItems) == CustomerOrderResponseGroup.WithItems) { query = query.Include(x => x.Items.Select(y => y.Discounts)).Include(x => x.Items.Select(y => y.TaxDetails)); } if ((responseGroup & CustomerOrderResponseGroup.WithShipments) == CustomerOrderResponseGroup.WithShipments) { query = query.Include(x => x.Shipments.Select(y => y.Discounts)) .Include(x => x.Shipments.Select(y => y.Items)) .Include(x => x.Shipments.Select(y => y.Addresses)) .Include(x => x.Shipments.Select(y => y.Properties)) .Include(x => x.Shipments.Select(y => y.TaxDetails)); } return(query.FirstOrDefault()); }
public CustomerOrderEntity GetCustomerOrderByNumber(string orderNumber, CustomerOrderResponseGroup responseGroup) { var id = CustomerOrders.Where(x => x.Number == orderNumber).Select(x => x.Id).FirstOrDefault(); if (id != null) { return(GetCustomerOrderById(id, responseGroup)); } return(null); }
public virtual CustomerOrder GetByOrderNumber(string orderNumber, CustomerOrderResponseGroup respGroup = CustomerOrderResponseGroup.Full) { CustomerOrder retVal = null; using (var repository = _repositoryFactory()) { var orderEntity = repository.GetCustomerOrderByNumber(orderNumber, CustomerOrderResponseGroup.WithAddresses); if (orderEntity != null) { retVal = GetById(orderEntity.Id, respGroup); } } return retVal; }
private BackupObject GetBackupObject() { var responce = _customerOrderSearchService.Search(new SearchCriteria { Count = int.MaxValue }); var orderIds = responce.CustomerOrders.Select(x => x.Id); const CustomerOrderResponseGroup filter = CustomerOrderResponseGroup.WithAddresses | CustomerOrderResponseGroup.WithItems | CustomerOrderResponseGroup.WithShipments | CustomerOrderResponseGroup.WithInPayments; return(new BackupObject { CustomerOrders = orderIds.Select(id => _customerOrderService.GetById(id, filter)).ToArray(), }); }
public virtual CustomerOrder GetByOrderNumber(string orderNumber, CustomerOrderResponseGroup respGroup = CustomerOrderResponseGroup.Full) { CustomerOrder retVal = null; using (var repository = _repositoryFactory()) { var orderEntity = repository.GetCustomerOrderByNumber(orderNumber, CustomerOrderResponseGroup.WithAddresses); if (orderEntity != null) { retVal = GetById(orderEntity.Id, respGroup); } } return(retVal); }
private BackupObject GetBackupObject(Action <ExportImportProgressInfo> progressCallback) { var retVal = new BackupObject(); var progressInfo = new ExportImportProgressInfo(); const CustomerOrderResponseGroup responseGroup = CustomerOrderResponseGroup.WithAddresses | CustomerOrderResponseGroup.WithItems | CustomerOrderResponseGroup.WithShipments | CustomerOrderResponseGroup.WithInPayments; var searchResponse = _customerOrderSearchService.Search(new SearchCriteria { Count = int.MaxValue }); progressInfo.Description = String.Format("{0} orders loading", searchResponse.CustomerOrders.Count()); progressCallback(progressInfo); retVal.CustomerOrders = searchResponse.CustomerOrders.Select((x) => _customerOrderService.GetById(x.Id, responseGroup)).ToList(); return(retVal); }
public virtual CustomerOrderEntity[] GetCustomerOrdersByIds(string[] ids, CustomerOrderResponseGroup responseGroup) { var query = CustomerOrders.Where(x => ids.Contains(x.Id)) .Include(x => x.Discounts) .Include(x => x.TaxDetails); if ((responseGroup & CustomerOrderResponseGroup.WithAddresses) == CustomerOrderResponseGroup.WithAddresses) { var addresses = Addresses.Where(x => ids.Contains(x.CustomerOrderId)).ToArray(); } if ((responseGroup & CustomerOrderResponseGroup.WithInPayments) == CustomerOrderResponseGroup.WithInPayments) { var inPayments = InPayments.Include(x => x.TaxDetails) .Include(x => x.Discounts) .Where(x => ids.Contains(x.CustomerOrderId)).ToArray(); var paymentsIds = inPayments.Select(x => x.Id).ToArray(); var paymentAddresses = Addresses.Where(x => paymentsIds.Contains(x.PaymentInId)).ToArray(); var transactions = Transactions.Where(x => paymentsIds.Contains(x.PaymentInId)).ToArray(); } if ((responseGroup & CustomerOrderResponseGroup.WithItems) == CustomerOrderResponseGroup.WithItems) { var lineItems = LineItems.Include(x => x.TaxDetails) .Include(x => x.Discounts) .Where(x => ids.Contains(x.CustomerOrderId)) .OrderByDescending(x => x.CreatedDate).ToArray(); } if ((responseGroup & CustomerOrderResponseGroup.WithShipments) == CustomerOrderResponseGroup.WithShipments) { var shipments = Shipments.Include(x => x.TaxDetails) .Include(x => x.Discounts) .Include(x => x.Items) .Include(x => x.Packages.Select(y => y.Items)) .Where(x => ids.Contains(x.CustomerOrderId)).ToArray(); var shipmentIds = shipments.Select(x => x.Id).ToArray(); var addresses = Addresses.Where(x => shipmentIds.Contains(x.ShipmentId)).ToArray(); } return(query.ToArray()); }
public PaymentInEntity GetInPaymentById(string id, CustomerOrderResponseGroup responseGroup) { throw new NotImplementedException(); }
public CustomerOrderEntity GetCustomerOrderById(string id, CustomerOrderResponseGroup responseGroup) { var query = CustomerOrders.Where(x => x.Id == id) .Include(x => x.Discounts) .Include(x => x.Properties) .Include(x => x.TaxDetails); if ((responseGroup & CustomerOrderResponseGroup.WithAddresses) == CustomerOrderResponseGroup.WithAddresses) { query = query.Include(x => x.Addresses); } if ((responseGroup & CustomerOrderResponseGroup.WithInPayments) == CustomerOrderResponseGroup.WithInPayments) { query = query.Include(x => x.InPayments.Select(y => y.Addresses)) .Include(x => x.InPayments.Select(y => y.Properties)); } if ((responseGroup & CustomerOrderResponseGroup.WithItems) == CustomerOrderResponseGroup.WithItems) { query = query.Include(x => x.Items.Select(y => y.Discounts)).Include(x => x.Items.Select(y => y.TaxDetails)); } if ((responseGroup & CustomerOrderResponseGroup.WithShipments) == CustomerOrderResponseGroup.WithShipments) { query = query.Include(x => x.Shipments.Select(y => y.Discounts)) .Include(x => x.Shipments.Select(y => y.Items)) .Include(x => x.Shipments.Select(y => y.Addresses)) .Include(x => x.Shipments.Select(y => y.Properties)) .Include(x => x.Shipments.Select(y => y.TaxDetails)); } return query.FirstOrDefault(); }
public virtual async Task <CustomerOrderEntity[]> GetCustomerOrdersByIdsAsync(string[] ids, CustomerOrderResponseGroup responseGroup) { var result = await CustomerOrders.Where(x => ids.Contains(x.Id)).ToArrayAsync(); var orderDiscounts = Discounts.Where(x => ids.Contains(x.CustomerOrderId)).ToArrayAsync(); var orderTaxDetails = TaxDetails.Where(x => ids.Contains(x.CustomerOrderId)).ToArrayAsync(); await Task.WhenAll(orderDiscounts, orderTaxDetails); if ((responseGroup & CustomerOrderResponseGroup.WithAddresses) == CustomerOrderResponseGroup.WithAddresses) { var addresses = await Addresses.Where(x => ids.Contains(x.CustomerOrderId)).ToArrayAsync(); } if ((responseGroup & CustomerOrderResponseGroup.WithInPayments) == CustomerOrderResponseGroup.WithInPayments) { var inPayments = await InPayments.Where(x => ids.Contains(x.CustomerOrderId)).ToArrayAsync(); var paymentsIds = inPayments.Select(x => x.Id).ToArray(); var paymentDiscounts = Discounts.Where(x => paymentsIds.Contains(x.PaymentInId)).ToArrayAsync(); var paymentTaxDetails = TaxDetails.Where(x => paymentsIds.Contains(x.PaymentInId)).ToArrayAsync(); var paymentAddresses = Addresses.Where(x => paymentsIds.Contains(x.PaymentInId)).ToArrayAsync(); var transactions = Transactions.Where(x => paymentsIds.Contains(x.PaymentInId)).ToArrayAsync(); await Task.WhenAll(paymentDiscounts, paymentTaxDetails, paymentAddresses, transactions); } if ((responseGroup & CustomerOrderResponseGroup.WithItems) == CustomerOrderResponseGroup.WithItems) { var lineItems = await LineItems.Where(x => ids.Contains(x.CustomerOrderId)) .OrderByDescending(x => x.CreatedDate).ToArrayAsync(); var lineItemIds = lineItems.Select(x => x.Id).ToArray(); var lineItemDiscounts = Discounts.Where(x => lineItemIds.Contains(x.LineItemId)).ToArrayAsync(); var lineItemTaxDetails = TaxDetails.Where(x => lineItemIds.Contains(x.LineItemId)).ToArrayAsync(); await Task.WhenAll(lineItemDiscounts, lineItemTaxDetails); } if ((responseGroup & CustomerOrderResponseGroup.WithShipments) == CustomerOrderResponseGroup.WithShipments) { var shipments = await Shipments.Where(x => ids.Contains(x.CustomerOrderId)).ToArrayAsync(); var shipmentIds = shipments.Select(x => x.Id).ToArray(); var shipmentDiscounts = Discounts.Where(x => shipmentIds.Contains(x.ShipmentId)).ToArrayAsync(); var shipmentTaxDetails = TaxDetails.Where(x => shipmentIds.Contains(x.ShipmentId)).ToArrayAsync(); var addresses = Addresses.Where(x => shipmentIds.Contains(x.ShipmentId)).ToArrayAsync(); var shipmentItems = ShipmentItems.Where(x => shipmentIds.Contains(x.ShipmentId)).ToArrayAsync(); var packages = ShipmentPackagesPackages.Include(x => x.Items).Where(x => shipmentIds.Contains(x.ShipmentId)).ToArrayAsync(); await Task.WhenAll(shipmentDiscounts, shipmentTaxDetails, addresses, shipmentItems, packages); } return(result); }
public CustomerOrderEntity GetCustomerOrderByNumber(string orderNumber, CustomerOrderResponseGroup responseGroup) { var id = CustomerOrders.Where(x => x.Number == orderNumber).Select(x => x.Id).FirstOrDefault(); if (id != null) { return GetCustomerOrderById(id, responseGroup); } return null; }
public CustomerOrderEntity GetCustomerOrderById(string id, CustomerOrderResponseGroup responseGroup) { var query = CustomerOrders.Where(x => x.Id == id) .Include(x => x.Discounts) .Include(x => x.TaxDetails); if ((responseGroup & CustomerOrderResponseGroup.WithAddresses) == CustomerOrderResponseGroup.WithAddresses) { var addresses = Addresses.Where(x => x.CustomerOrderId == id).ToArray(); } if ((responseGroup & CustomerOrderResponseGroup.WithInPayments) == CustomerOrderResponseGroup.WithInPayments) { var inPayments = InPayments.Where(x => x.CustomerOrderId == id).ToArray(); var paymentsIds = inPayments.Select(x => x.Id).ToArray(); var paymentAddresses = Addresses.Where(x => paymentsIds.Contains(x.PaymentInId)).ToArray(); } if ((responseGroup & CustomerOrderResponseGroup.WithItems) == CustomerOrderResponseGroup.WithItems) { var lineItems = LineItems.Include(x => x.TaxDetails) .Include(x => x.Discounts) .Where(x => x.CustomerOrderId == id).ToArray(); } if ((responseGroup & CustomerOrderResponseGroup.WithShipments) == CustomerOrderResponseGroup.WithShipments) { var shipments = Shipments.Include(x => x.TaxDetails) .Include(x => x.Discounts) .Include(x => x.Items) .Include(x => x.Packages.Select(y => y.Items)) .Where(x=>x.CustomerOrderId == id).ToArray(); var shipmentIds = shipments.Select(x => x.Id).ToArray(); var addresses = Addresses.Where(x => shipmentIds.Contains(x.ShipmentId)).ToArray(); } return query.FirstOrDefault(); }
public CartSearchCriteriaBuilder AddResponseGroup(CustomerOrderResponseGroup responseGroup) { _searchCriteria.ResponseGroup = responseGroup.ToString(); return(this); }
public virtual CustomerOrderEntity[] GetCustomerOrdersByIds(string[] ids, CustomerOrderResponseGroup responseGroup) { var result = Array.Empty <CustomerOrderEntity>(); if (!ids.IsNullOrEmpty()) { result = CustomerOrders.Where(x => ids.Contains(x.Id)).ToArray(); if (result.Any()) { ids = result.Select(x => x.Id).ToArray(); var orderDiscounts = Discounts.Where(x => ids.Contains(x.CustomerOrderId)).ToArray(); var orderTaxDetails = TaxDetails.Where(x => ids.Contains(x.CustomerOrderId)).ToArray(); if (responseGroup.HasFlag(CustomerOrderResponseGroup.WithAddresses)) { var addresses = Addresses.Where(x => ids.Contains(x.CustomerOrderId)).ToArray(); } if (responseGroup.HasFlag(CustomerOrderResponseGroup.WithInPayments)) { var inPayments = InPayments.Where(x => ids.Contains(x.CustomerOrderId)).ToArray(); var paymentsIds = inPayments.Select(x => x.Id).ToArray(); if (paymentsIds.Any()) { var paymentDiscounts = Discounts.Where(x => paymentsIds.Contains(x.PaymentInId)).ToArray(); var paymentTaxDetails = TaxDetails.Where(x => paymentsIds.Contains(x.PaymentInId)).ToArray(); var paymentAddresses = Addresses.Where(x => paymentsIds.Contains(x.PaymentInId)).ToArray(); var transactions = Transactions.Where(x => paymentsIds.Contains(x.PaymentInId)).ToArray(); } } if (responseGroup.HasFlag(CustomerOrderResponseGroup.WithItems)) { var lineItems = LineItems.Where(x => ids.Contains(x.CustomerOrderId)) .OrderByDescending(x => x.CreatedDate).ToArray(); var lineItemIds = lineItems.Select(x => x.Id).ToArray(); if (lineItemIds.Any()) { var lineItemDiscounts = Discounts.Where(x => lineItemIds.Contains(x.LineItemId)).ToArray(); var lineItemTaxDetails = TaxDetails.Where(x => lineItemIds.Contains(x.LineItemId)).ToArray(); } } if (responseGroup.HasFlag(CustomerOrderResponseGroup.WithShipments)) { var shipments = Shipments.Where(x => ids.Contains(x.CustomerOrderId)).ToArray(); var shipmentIds = shipments.Select(x => x.Id).ToArray(); if (shipmentIds.Any()) { var shipmentDiscounts = Discounts.Where(x => shipmentIds.Contains(x.ShipmentId)).ToArray(); var shipmentTaxDetails = TaxDetails.Where(x => shipmentIds.Contains(x.ShipmentId)).ToArray(); var addresses = Addresses.Where(x => shipmentIds.Contains(x.ShipmentId)).ToArray(); var shipmentItems = ShipmentItems.Where(x => shipmentIds.Contains(x.ShipmentId)).ToArray(); var packages = ShipmentPackagesPackages.Include(x => x.Items) .Where(x => shipmentIds.Contains(x.ShipmentId)).ToArray(); } } if (!responseGroup.HasFlag(CustomerOrderResponseGroup.WithPrices)) { foreach (var customerOrder in result) { customerOrder.ResetPrices(); } } } } return(result); }