public void TakeFrom(Models.Location loc, Models.Products prod) { int locId = _repo.GetLocationID(loc); int prodId = _repo.GetProductID(prod); _repo.ReduceInventory(locId, prodId); }
public List <Models.Products> GetAllProducts() { List <Models.Products> prods = new List <Models.Products>(); foreach (Entities.Product r in _context.Products) { Models.Products p = new Models.Products(r.Price, r.Description); prods.Add(p); } return(prods); }
public int GetProductID(Models.Products prod) { List <Entities.Product> products = new List <Entities.Product>(); foreach (Entities.Product r in _context.Products) { products.Add(r); } int id = (from rec in products where rec.Description == prod.ItemName select rec.Id).FirstOrDefault(); return(id); }
public Models.Products AddLineItem(Models.Products product, int orderId) { List <Entities.Product> prods = new List <Entities.Product>(); foreach (Entities.Product prod in _context.Products) { prods.Add(prod); } int prodId = (from Prod in prods where Prod.Description == product.ItemName select Prod.Id).FirstOrDefault(); _context.LineItems.Add( new Entities.LineItem { OrderId = orderId, ProductId = prodId, Quantity = 1 } ); _context.SaveChanges(); return(product); }