public override Specification <Mapping> GetSpecification() { var spec = new Specification <Mapping>(); if (!Ids.IsEmpty()) { int[] ids = ArrayHelpers.StringToIntArray(Ids); if (ids != null && ids.Length > 0) { spec.And(c => ids.Contains(c.Id)); } } if (!ProductIds.IsEmpty()) { int[] ids = ArrayHelpers.StringToIntArray(ProductIds); if (ids != null && ids.Length > 0) { spec.And(c => ids.Contains(c.ProductId)); } } if (StoreId.HasValue) { spec.And(m => m.StoreId.Equals(StoreId.Value)); } if (!Sku.IsEmpty()) { spec.And(m => m.Product.Sku.StartsWith(Sku)); } if (!StoreSku.IsEmpty()) { spec.And(m => m.StoreSku.StartsWith(StoreSku)); } return(spec); }
public async Task <object> GetOrderAsync([FromRoute] int id) { IQueryable <Object> ProductIds; Order OrderObj = new Order(); OrderObj.Order_Id = id; ProductIds = (from products in _context.Orders_Products where products.Order_ref.Equals(OrderObj) select products.Product_ref); List <Product> ProductsToShow = ProductIds.Cast <Product>().ToList(); //foreach(var item in ids) //{ // ProductsToShow.Add((Product)item); //} // ProductsToShow = (Product)ids; int count = ProductsToShow.Count; if (!ModelState.IsValid) { return(BadRequest(ModelState)); } Order order = await _context.Orders.FindAsync(id); if (order == null) { return(NotFound()); } return(new { order, ProductsToShow }); }
/// <summary> /// ((PromotionEvaluationContext)x).IsItemInProduct(ProductId) /// </summary> /// <returns></returns> public linq.Expression <Func <IEvaluationContext, bool> > GetConditionExpression() { if (ProductId == null && ProductIds == null) { throw new ArgumentException($"{nameof(ProductId)} and {nameof(ProductIds)} cannot be null."); } var paramX = linq.Expression.Parameter(typeof(IEvaluationContext), "x"); var castOp = linq.Expression.MakeUnary(linq.ExpressionType.Convert, paramX, typeof(PromotionEvaluationContext)); linq.MethodCallExpression methodCall = null; if (ProductIds != null) { var methodInfo = typeof(PromotionEvaluationContextExtension).GetMethod("IsItemInProducts"); methodCall = linq.Expression.Call(null, methodInfo, castOp, ProductIds.GetNewArrayExpression()); } else { var methodInfo = typeof(PromotionEvaluationContextExtension).GetMethod("IsItemInProduct"); methodCall = linq.Expression.Call(null, methodInfo, castOp, linq.Expression.Constant(ProductId)); } var retVal = linq.Expression.Lambda <Func <IEvaluationContext, bool> >(methodCall, paramX); return(retVal); }
public override void ExecuteApiManagementCmdlet() { string id = ApiId ?? Guid.NewGuid().ToString("N"); var newApi = Client.ApiCreate( Context, id, Name, Description, ServiceUrl, Path, SourceApiId, SourceApiRevision, SubscriptionRequired.IsPresent, ApiVersionDescription, ApiVersionSetId, ApiVersion, Protocols.Distinct().ToArray(), AuthorizationServerId, AuthorizationScope, SubscriptionKeyHeaderName, SubscriptionKeyQueryParamName, OpenIdProviderId, BearerTokenSendingMethod); if (ProductIds != null && ProductIds.Any()) { WriteProgress(new ProgressRecord(0, "New-AzApiManagementApi", "New API created. Adding to products...")); foreach (var productId in ProductIds) { try { Client.ApiAddToProduct(Context, productId, id); WriteProgress( new ProgressRecord( 0, "New-AzApiManagementApi", string.Format("... Added to product {0}", productId)) ); } catch (Exception ex) { WriteProgress( new ProgressRecord( 0, "New-AzApiManagementApi", string.Format("... Failed to add to product {0} due to: {1}", productId, ex)) ); } } } WriteObject(newApi); }
public override IPromotionValidationResult Validate(IPromotionController promotionController, IRuleContext ruleContext) { if (this.AndTogether) { // validate all in list are in cart foreach (Int32 productId in ProductIds) { if (!ruleContext.ShoppingCartItems.Select(s => s.ProductId).Contains(productId)) { return(new SimplePromotionValidationResult(false, "Promotion.Reason.ProductId.NoMatch")); } } } else { if (!ruleContext.ShoppingCartItems.Where(w => ProductIds.Contains(w.ProductId)).Any()) { return(new SimplePromotionValidationResult(false, "Promotion.Reason.ProductId.NoMatch")); } } if (RequireQuantity) { var requiredProductsInCart = ruleContext.ShoppingCartItems .Where(w => ProductIds.Contains(w.ProductId)) .Select(item => new { CartItem = item, SufficientQuantity = item.Quantity >= Quantity, }); var sufficientQuantityItems = requiredProductsInCart .Where(o => o.SufficientQuantity) .Select(o => o.CartItem); var insufficientQuantityItems = requiredProductsInCart .Where(o => !o.SufficientQuantity) .Select(o => o.CartItem); if (!sufficientQuantityItems.Any() || (this.AndTogether && insufficientQuantityItems.Any())) { var reason = new PromotionValidationResultReason("Promotion.Reason.ProductId.InsufficientQuantity"); reason.ContextItems.Add("ProductName", insufficientQuantityItems.First().Name); reason.ContextItems.Add("QuantityDelta", Quantity - insufficientQuantityItems.First().Quantity); return(new SimplePromotionValidationResult(false, reason)); } } return(new SimplePromotionValidationResult(true)); }
private void btnAddSearch_Click(object sender, EventArgs e) { ProductQuery query = new ProductQuery(); query.Keywords = txtSearchText.Text; query.CategoryId = dropCategories.SelectedValue; query.SaleStatus = ProductSaleStatus.OnSale; IList <int> productIds = SubSiteProducthelper.GetProductIds(query); foreach (int num in productIds) { if (!ProductIds.Contains(num)) { ProductIds.Add(num); SubsitePromoteHelper.InsertPromotionProduct(activeId, num); } } ProductIds = productIds; BindPromoteProducts(); }
public override Specification <Adjustment> GetSpecification() { var spec = new Specification <Adjustment>(); if (!Ids.IsEmpty()) { int[] ids = ArrayHelpers.StringToIntArray(Ids); if (ids != null && ids.Length > 0) { spec.And(c => ids.Contains(c.Id)); } } if (!ProductIds.IsEmpty()) { int[] ids = ArrayHelpers.StringToIntArray(ProductIds); if (ids != null && ids.Length > 0) { spec.And(c => ids.Contains(c.ProductId)); } } if (AdjustmentTypeId.HasValue) { spec.And(a => a.AdjustmentTypeId == AdjustmentTypeId.Value); } if (StoreId.HasValue) { spec.And(a => a.StoreId == StoreId.Value); } if (!Sku.IsEmpty()) { spec.And(r => r.Product.Sku.StartsWith(Sku)); } if (!ReferenceNumber.IsEmpty()) { spec.And(r => r.ReferenceNumber.StartsWith(ReferenceNumber)); } return(spec); }
public override Specification <Reservation> GetSpecification() { var spec = new Specification <Reservation>(); if (!Ids.IsEmpty()) { int[] ids = ArrayHelpers.StringToIntArray(Ids); if (ids != null && ids.Length > 0) { spec.And(c => ids.Contains(c.Id)); } } if (!ProductIds.IsEmpty()) { int[] ids = ArrayHelpers.StringToIntArray(ProductIds); if (ids != null && ids.Length > 0) { spec.And(c => ids.Contains(c.ProductId)); } } if (!OrderNumber.IsEmpty()) { spec.And(r => r.OrderNumber == OrderNumber); } if (!Sku.IsEmpty()) { spec.And(r => r.Product.Sku.StartsWith(Sku)); } if (!ShowAll) { spec.And(r => r.Quantity > 0); } return(spec); }
public ShoppingCartController(ShoppingContext shoppingContext, ProductIds productIds) { _dbContext = shoppingContext; productService = new ProductService(shoppingContext); _productIds = productIds; }
public ProductsController(ShoppingContext shoppingContext, ProductIds productIds) { _dbContext = shoppingContext; _productIds = productIds; }
protected void Page_Load(object sender, EventArgs e) { if (ProductIds.Count == 0) { return; } var finalList = new List <Product>(); foreach (var id in ProductIds) { finalList.AddRange(ProductService.GetRelatedProducts(id, RelatedType).Where(product => !ProductIds.Contains(product.ProductId) && finalList.All(item => product.ID != item.ID))); } lvRelatedProducts.DataSource = finalList.Distinct(); lvRelatedProducts.DataBind(); HasProducts = lvRelatedProducts.Items.Any(); }
protected void Page_Load(object sender, EventArgs e) { if (ProductIds.Count == 0) { return; } LoadModules(); var finalList = new List <Product>(); foreach (var id in ProductIds) { finalList.AddRange(ProductService.GetRelatedProducts(id, RelatedType).Where(product => !ProductIds.Contains(product.ProductId) && finalList.All(item => product.ID != item.ID))); } lvRelatedProducts.DataSource = finalList.Distinct().OrderByDescending(p => p.MainPrice > 0).ThenByDescending(p => p.TotalAmount > 0 || p.AllowPreOrder); lvRelatedProducts.DataBind(); HasProducts = lvRelatedProducts.Items.Any(); }
public override bool IsSatisfiedBy(IEvaluationContext context) { return(context is DynamicContentEvaluationContext dynamicContentContext && !dynamicContentContext.ProductId.IsNullOrEmpty() && (ProductIds?.Contains(dynamicContentContext.ProductId) ?? false)); }
public int GetFirstProductId() { return(ProductIds.ToArray()[0]); }