/// <summary> /// Add a coffee product to the current customers order /// Multiplies given coffee product by amount purchased and passes to /// AddToTotal_ method /// </summary> /// <param name="coffeeProduct"></param> /// <param name="quantity"></param> public void AddProductToOrder(CoffeeTypes coffeeProduct, int quantity) { Coffee coffee = new Coffee(); double coffeePrice = 0.00; using var context = new joshfordproject0Context(s_dbContextOptions); IQueryable <Product> menu = context.Products .OrderBy(x => x.ProductName); foreach (Product products in menu) { if (coffeeProduct.ToString().Equals(products.ProductName)) { coffeePrice = products.ProductPrice; } } /* * coffeePrice = double.Parse(context.Products * .Select(x => x.ProductPrice) * .Where(x => x.Equals(custCoffee)) * .ToString()); */ customerCoffee.Add(coffeeProduct); AddToTotalOrderPrice(coffeePrice * quantity); }
/// <summary> /// Checks the given coffee products current amount in the store inventory /// </summary> /// <param name="productToCheck"></param> public void CheckProductInventory(Enum productToCheck) { using var context = new joshfordproject0Context(s_dbContextOptions); CoffeeTypes coffeeInvCheck = (CoffeeTypes)productToCheck; int productAmount = 0; // SQL Query for coffee Inventory Console.WriteLine($"Current amount of {coffeeInvCheck} is: {productAmount}"); }
/// <summary> /// Retrieves a given products price /// </summary> /// <param name="productToPrice"></param> public void GetProductPrice(Enum productToPrice) { using var context = new joshfordproject0Context(s_dbContextOptions); CoffeeTypes coffeeToPrice = (CoffeeTypes)productToPrice; var priceOfCoffee = context.Products .Select(x => x.ProductPrice) .Where(x => x.Equals(coffeeToPrice.ToString())); Console.WriteLine($"{coffeeToPrice}: $ {priceOfCoffee}"); }
void MakeCoffee(CoffeeTypes coffeeName) { var chosenCoffee = coffeeTypes.Find(coffee => coffee.name == coffeeName); if (CheckState(chosenCoffee)) { this.water -= chosenCoffee.water; this.milk -= chosenCoffee.milk; this.beans -= chosenCoffee.beans; this.money += chosenCoffee.cost; this.cups--; } }
public void Order_AddCoffeeToOrder_OrderHasCoffee() { // Arrange OrderC expected = new OrderC(1, 1, 1); CoffeeTypes coffeeProduct = CoffeeTypes.Regular; int coffeeQuantity = 1; expected.AddProductToOrder(coffeeProduct, coffeeQuantity); // Act OrderC actual = new OrderC(1, 1, 1); actual.AddProductToOrder(CoffeeTypes.Regular, 1); // Assert Assert.Equal(expected, actual); }
public IBeverage ToBeverage() { if (!IsBrewed) { throw new Exception("Error: coffee hasn't been brewed yet"); } Type coffeeType = CoffeeTypes.GetCoffeeType(Ingredients); // Ingredients for espresso if (coffeeType == typeof(Espresso)) { return(this); } if (coffeeType != typeof(CustomBeverage)) { return((IBeverage)Activator.CreateInstance(coffeeType)); } return(new CustomBeverage(Ingredients)); }