public IList <CartBase> GetAll(GetCartsRequest getCartsRequest) { using (new DisposableThreadLifestyleScope()) { var userIds = getCartsRequest.UserIds.ToList(); var customerIds = getCartsRequest.CustomerIds.ToList(); var names = getCartsRequest.Names.ToList(); var statuses = getCartsRequest.Statuses; var isLocked = getCartsRequest.IsLocked; var repository = ObjectFactory.Instance.Resolve <IRepository <PurchaseOrder> >(); var purchaseOrders = repository.Select() .Where(x => (!customerIds.Any() || customerIds.Contains(x.Customer.CustomerId.ToString())) && (!userIds.Any() || x.OrderProperties.Any( y => y.Key == "CommerceConnectUserIdentifier" && userIds.Contains(y.Value))) && (!names.Any() || names.Contains(x.ProductCatalogGroup.DomainId)) && x.OrderStatus.OrderStatusId == 1); var cartBases = new List <CartBase>(); foreach (var purchaseOrder in purchaseOrders) { cartBases.Add( ObjectFactory.Instance.Resolve <IMapping <PurchaseOrder, CartBase> >("PurchaseOrderToCartBase") .Map(purchaseOrder)); } return(cartBases.Distinct().ToList()); } }
public IQueryable <CartBase> Get(string userId = null, string customerId = null, string cartName = null, string cartStatus = null) { var request = new GetCartsRequest(Context.Site.Name); if (userId != null) { request.UserIds = new[] { userId }; } if (customerId != null) { request.CustomerIds = new[] { customerId }; } if (cartName != null) { request.Names = new[] { cartName }; } if (cartStatus != null) { request.Statuses = new[] { cartStatus }; } var result = this.cartService.GetCarts(request); return(result.Carts .OrderBy(c => c.ShopName) .ThenBy(c => c.CustomerId) .ThenBy(c => c.UserId) .ThenBy(c => c.Name) .AsQueryable()); }
/// <summary> /// Initializes a new instance of the <see cref="GetCartsTest" /> class. /// </summary> public GetCartsTest() { this.request = new GetCartsRequest("MyShop"); this.result = new GetCartsResult(); this.args = new ServicePipelineArgs(this.request, this.result); this.client = Substitute.For <ICartsServiceChannel>(); var clientFactory = Substitute.For <ServiceClientFactory>(); clientFactory.CreateClient <ICartsServiceChannel>(Arg.Any <string>(), Arg.Any <string>()).Returns(this.client); this.processor = new GetCarts { ClientFactory = clientFactory }; }