public virtual void EmbeddingOfInstanceOfCustomReferenceTypeWithFieldsIsCorrect() { // Arrange var product = new Product { Name = "Red T-shirt", Price = 995.00 }; const string updateCode = "product.Price *= 1.15;"; const string input1 = "product.Name"; const string targetOutput1 = "Red T-shirt"; const string input2 = "product.Price"; const double targetOutput2 = 1144.25; // Act string output1; double output2; using (var jsEngine = CreateJsEngine()) { jsEngine.EmbedHostObject("product", product); jsEngine.Execute(updateCode); output1 = jsEngine.Evaluate<string>(input1); output2 = jsEngine.Evaluate<double>(input2); } // Assert Assert.AreEqual(targetOutput1, output1); Assert.AreEqual(targetOutput2, output2); }
private void AddItem(Product item) { var cartItem = cartItems.SingleOrDefault(x => x.Name == item.Name); if(cartItem != null) { cartItem.AddItem(); } else { cartItems.Add(new CartItem(item)); } }
public IActionResult OnGet(int id) { TaxPayer = taxPayerService.Get(id); SelectDDV = ddvService.GetAll().Select(d => new SelectListItem { Text = d.Tax.ToString(), Value = d.Id.ToString() }); Product = new Core.Product(); return(Page()); }
private static void PopulateProduct(Product product) { try { var htmlDoc = GetDocument(product.Url); var sku = htmlDoc.DocumentNode.SelectSingleNode("//*[@id='info-sku']").InnerText.Replace("Product #", string.Empty); product.SKU = sku; var priceText = htmlDoc.DocumentNode.SelectSingleNode("//*[@id='info-prod-price']").InnerText.Split(';')[1]; product.Price = decimal.Parse(priceText); var name = htmlDoc.DocumentNode.SelectSingleNode("//*[@id='breadcrumb-text']").InnerText.Split('>')[1]; product.Name = name; var descriptionNode = htmlDoc.DocumentNode.SelectSingleNode("//*[@id='info-product-description']"); if (descriptionNode != null) { var description = descriptionNode.InnerText; product.Description = description; } else { product.Description = string.Empty; } var imageUrl = htmlDoc.DocumentNode.SelectSingleNode("//*[@id='info-image']/img").GetAttributeValue("src", ""); product.ImageUrl = imageUrl; product.LoadComplete = true; } catch { } }
private bool hasProductWithUser(State S, Product P, User U) { foreach (Product pr in S.Products) { if (pr.Equals(P)) { foreach (User usr in pr.Users) { if (usr.Equals(U)) return true; } } } return false; }
public OrderLineItem(Product product, int quantity) { ProductInfo = product; Quantity = quantity; }