public string AddProduct(string productName, decimal price, string producer) { var newProduct = new Product(productName, price, producer); if (!this.productsByName.ContainsKey(productName)) { this.productsByName.Add(productName, new List<Product>()); } if (!this.productsProducere.ContainsKey(producer)) { this.productsProducere.Add(producer, new List<Product>()); } if (!this.productsByNameNadProducer.ContainsKey(productName + producer)) { this.productsByNameNadProducer.Add(productName + producer, new List<Product>()); } if (!this.productsByPrice.ContainsKey(price)) { this.productsByPrice.Add(price, new List<Product>()); } this.productsByName[productName].Add(newProduct); this.productsProducere[producer].Add(newProduct); this.productsByNameNadProducer[productName + producer].Add(newProduct); this.productsByPrice[price].Add(newProduct); return "Product added"; }
public OrderItem(Product product, int quantity) { _product = product; _quantity = quantity; }
public Product GetProduct(int id) { using (var context = DbContextFactory.Create()) { // Call dapper to make the proc call but just use the EntityFramework connection var dbProduct = context.Database.Connection .Query("select * from vw_productAll_Web where ProductId = @productId", new { productId = id }, commandType: CommandType.Text) .Single(); var images = context.Database.Connection .Query("ProductPartPhotos_get", new { ProductID = id, PartID = dbProduct.PartID }, commandType: CommandType.StoredProcedure) .ToList(); var product = new Product { ProductId = dbProduct.ProductId, AvailableQty = dbProduct.AvailableQty, Title = dbProduct.Title, QuickOverview = dbProduct.QuickOverview, ImageId = dbProduct.ImageId, IsAvailable = dbProduct.IsAvailable == 1 ? true : false, IsNew = (bool)dbProduct.IsNew, IsBestSeller = (bool)dbProduct.IsBestSeller, IsFeatured = (bool)dbProduct.IsFeatured, CategoryId = dbProduct.CategoryID, Price = dbProduct.Price, Description = dbProduct.Description, CreatedDateTime = dbProduct.CreatedDateTime, Images = images.Select(i => (string)i.PhotoName).ToArray(), ProductSpecifications = new { Make = dbProduct.Make, Model = dbProduct.Model, Chassis = dbProduct.ChassisNo, Engine = dbProduct.EngineSize, EngineNo = dbProduct.EngineNo, FuelType = dbProduct.FuelType, WheelBase = dbProduct.WheelBase, Body = dbProduct.BodyType, Year = dbProduct.Year, }, OtherDetails = new { PartNo = dbProduct.PartNo, Part = dbProduct.Part, Height = dbProduct.Height, Width = dbProduct.Width, Length = dbProduct.Length, Weight = dbProduct.Weight, Colour = dbProduct.Colour, Side = dbProduct.Side }, DefectNotes = dbProduct.DeffectNotes }; return product; } }
public void UpdateProduct(Product product) { using (var context = DbContextFactory.Create()) { var dbProduct = context.Products.Single(p => p.ProductId == product.ProductId); Mapper.Map(product, dbProduct); context.SaveChanges(); } }
private void ParseProducts(string xml, List<Product> products) { xml = xml.Replace(@"xmlns=""http://webservices.amazon.com/AWSECommerceService/2005-03-23""", String.Empty); XDocument doc = XDocument.Parse(xml); foreach (XElement itemElement in doc.Descendants("Item")) { try { XElement imageElement = itemElement.Element("MediumImage"); XElement reviewsElement = itemElement.Element("EditorialReviews"); XElement descriptionElement = (reviewsElement != null) ? reviewsElement.Descendants("Content").FirstOrDefault() : null; Product p = new Product { ASIN = itemElement.Element("ASIN").Value, Title = itemElement.Element("ItemAttributes").Element("Title").Value, Price = Int32.Parse(itemElement.Element("ItemAttributes").Element("ListPrice").Element("Amount").Value) / 100m, ProductUri = itemElement.Element("DetailPageURL").Value, ImageUri = (imageElement != null) ? imageElement.Element("URL").Value : null, Description = (descriptionElement != null) ? TagRegex.Replace(descriptionElement.Value, String.Empty) : null }; products.Add(p); } catch { } } }
public void AddItem(Product product, int quantity) { Order.AddItem(product, quantity); RaisePropertyChanged("CanCheckout"); }