public static string PriceOfSelectedHoney(string selectedHoney) { if (selectedHoney != "--Вибрати мед--") { ProductCRUD productCrud = new ProductCRUD(); Product product = productCrud.GetList() .Where(x => x.Name == selectedHoney) .FirstOrDefault(); if (product.Discount != 0) { product.Cost = product.Cost - (product.Cost * product.Discount / 100); } //if (product.Remains < 0.5) //{ // product.Remains = 0; //} string jsonProduct = new JavaScriptSerializer().Serialize(product); return jsonProduct; } else { Product defaultProduct = new Product(); defaultProduct.Name = "--Вибрати мед--"; string jsonDefaultProduct = new JavaScriptSerializer().Serialize(defaultProduct); return jsonDefaultProduct; } }
void SetNewPrice(Product product, RepeaterItemEventArgs e) { Label oldPrice = (Label)e.Item.FindControl("oldPrice"); Label newPrice = (Label)e.Item.FindControl("newPrice"); int discountPrice = product.Cost - (product.Cost * product.Discount / 100); oldPrice.CssClass = "ProductOldPrice"; newPrice.Text = string.Format("Нова Ціна: {0}грн.л", discountPrice.ToString()); }
void SetDiscountImage(Product product, Image image) { int discount = product.Discount; if (image == null || discount == 0) { image.Attributes["style"] = "visibility: collapse;"; return; } try { image.ImageUrl = string.Format("~/Pictures/{0}.jpg",discount.ToString()); } catch { return; } }
void SetLightBox(Product product, JqueryLightBoxControl lightBoxControl) { if (lightBoxControl == null) { return; } List<string> names = Directory.GetFiles(Server.MapPath("~/Pictures"), "*.jpg") .Select(x => Path.GetFileNameWithoutExtension(x)) .OrderBy(x => x.Length) .ToList(); for (int i = 0; i < names.Count; i++) { if (product.Name == names[i]) { lightBoxControl.Title = names[i]; return; } } lightBoxControl.SetUrl = "~/Pictures/NoImage.png"; lightBoxControl.Title = "none"; }