public static void AddOrder(this Order Order, Product product, int quantity) { if (!Order.Contains(product)) Order.OrderItems.Add(new OrderItem(product, quantity, product.Price)); else Order.EditOrder(product, quantity); }
public static void EditOrder(this Order Order, Product product, int quantity) { double price = product.Price; price = Order.OrderItems.Where(x => x.Product == product).Select(x => x.Price).First(); Order.RemoveOrder(product); Order.OrderItems.Add(new OrderItem(product, quantity, price)); }
public int SaveProduct(Product product) { var parameters = new DynamicParameters(); parameters.Add("@EanCode", product.EanCode, DbType.String); parameters.Add("@OrderId", product.OrderId, DbType.Int32); parameters.Add("@ManufacturerName", product.ManufacturerName, DbType.String); parameters.Add("@ManufacturerInn", product.ManufacturerInn, DbType.String); parameters.Add("@ManufacturerKpp", product.ManufacturerKpp, DbType.String); parameters.Add("@ProductName", product.ProductName, DbType.String); parameters.Add("@Volume", product.Volume, DbType.Decimal); parameters.Add("@PercentAlc", product.PercentAlc, DbType.Decimal); parameters.Add("@Price", product.Price, DbType.Decimal); parameters.Add("@Count", product.Count, DbType.Int32); using (var conn = Connection) { conn.Open(); return conn.Query<int>("dbo.SaveProduct", parameters, commandType: CommandType.StoredProcedure).FirstOrDefault(); } }
private void SaveProduct() { if (_product.Id != 0) { _product.Comments = _productComments; _product.Category = _category; _product.Price = _price; _product.Quantity = _quantity; _product.SKU = _sku; _product.Title = _title; _product.Id = _id; _product.IsActive = _isActive; _model.Save(_product); } else { var newProductToSave = new Product(_productComments) { Category = _category, Price = _price, Quantity = _quantity, SKU = _sku, Title = _title, Id = ID, IsActive = _isActive }; _model.Create(newProductToSave); _id = newProductToSave.Id; _product = newProductToSave; } }
public void UseProductWithID(int id) { _product = _model.Find(id); InitializeProductFields(); }
public int SaveProduct(Product product) { return _productRepository.SaveProduct(product); }
public void Delete(Product entity) { dbContext.Products.Remove(entity); dbContext.SaveChanges(); }
public void Create(Product entity) { dbContext.Products.Add(entity); dbContext.SaveChanges(); }
public void Update(Product entity) { dbContext.Entry(entity).State = System.Data.Entity.EntityState.Modified; dbContext.SaveChanges(); }
public static void RemoveOrder(this Order Order, Product product) { Order.OrderItems.RemoveAll(x => x.Product == product); }
public static bool Contains(this Order Order, Product product) { return Order.OrderItems.Any(x => x.Product == product); }
public static bool Contains(this Order Order, Product product) { return Order.OrderItems.Where(x => x.Product == product).Count() > 0; }
public OrderItem(Product product, int quantity, double price) { Product = product; Quantity = quantity; Price = price; }
public void Save(Product productToSave) { ProductRepository.Update(productToSave); }
public void Create(Product productToSave) { ProductRepository.Create(productToSave); }