//CreateBasket public Basket CreateBasket(BasketOption baskOption) { CustomerManagement cstMng = new CustomerManagement(db); Basket basket = new Basket { Customer = cstMng.FindCustomerById(baskOption.CustomerId) }; db.Baskets.Add(basket); db.SaveChanges(); return(basket); }
public BasketProduct AddProduct(BasketProductOption bskProd) { CustomerManagement cstMng = new CustomerManagement(db); BasketProduct basketProduct = new BasketProduct { Basket = db.Baskets.Find(bskProd.BasketId), Product = db.Products.Find(bskProd.ProductId) }; db.BasketProducts.Add(basketProduct); db.SaveChanges(); return(basketProduct); }
//Create Basket public Basket CreateBasket(BasketOption baskOption) { CustomerManagement castMangr = new CustomerManagement(db); Basket basket = new Basket { Customer = castMangr.FindCustomerById(baskOption.CustomerId) }; // db.Database.EnsureCreated(); db.Baskets.Add(basket); db.SaveChanges(); return(basket); }