예제 #1
0
 public PrepareOrderMessage(String customerName, String drink, DrinkSize size, Guid orderId)
 {
     CustomerName = customerName;
     Drink        = drink;
     DrinkSize    = size;
     OrderId      = orderId;
 }
예제 #2
0
 public OrderPlaced(String customerName, String drink, DrinkSize size, Guid orderId)
 {
     CustomerName = customerName;
     Drink = drink;
     DrinkSize = size;
     OrderId = orderId;
 }
 public CustomerRefusesToPayView(String customerName, Decimal amount, String drink, DrinkSize drinkSize)
 {
     CustomerName = customerName;
     Amount = amount;
     Drink = drink;
     DrinkSize = drinkSize.ToString();
 }
예제 #4
0
 public NewOrderMessage(String customerName, String drink, DrinkSize drinkSize)
 {
     CustomerName = customerName;
     Drink        = drink;
     DrinkSize    = drinkSize;
     OrderId      = Guid.NewGuid();
 }
예제 #5
0
 public PrepareOrderMessage(String customerName, String drink, DrinkSize size, Guid orderId)
 {
     CustomerName = customerName;
     Drink = drink;
     DrinkSize = size;
     OrderId = orderId;
 }
예제 #6
0
 public OrderPlaced(String customerName, String drink, DrinkSize size, Guid orderId)
 {
     CustomerName = customerName;
     Drink        = drink;
     DrinkSize    = size;
     OrderId      = orderId;
 }
예제 #7
0
파일: Menu.cs 프로젝트: OOualiken/CleanCode
 public Menu(DishType DishType, DrinkSize DrinkSize, DessertType DessertType = DessertType.Normal, bool HasCoffee = false)
 {
     this.DishType    = DishType;
     this.DrinkSize   = DrinkSize;
     this.DessertType = DessertType;
     this.HasCoffee   = HasCoffee;
 }
예제 #8
0
        public void UpdateDrinkSize(DrinkSize drinkSize)
        {
            var oDrinkSize = _appDbContext.DrinkSizes.FirstOrDefault(ds => ds.Id == drinkSize.Id);

            if (oDrinkSize == null)
            {
                _appDbContext.DrinkSizes.Add(drinkSize);
            }
            else
            {
                _appDbContext.Entry(oDrinkSize).State = EntityState.Detached;
                _appDbContext.Entry(drinkSize).State  = EntityState.Modified;
                _appDbContext.Update(drinkSize);
            };

            if (drinkSize.IsPrimary)
            {
                var sizes = _appDbContext.DrinkSizes.Where(s => s.Id != drinkSize.Id && s.DrinkId == drinkSize.DrinkId);
                foreach (var s in sizes)
                {
                    s.IsPrimary = false;
                }
            }

            _appDbContext.SaveChanges();
        }
예제 #9
0
 public NewOrderMessage(String customerName, String drink, DrinkSize drinkSize)
 {
     CustomerName = customerName;
     Drink = drink;
     DrinkSize = drinkSize;
     OrderId = Guid.NewGuid();
 }
예제 #10
0
 public static AvailableSize From(DrinkSize drinkSize) =>
 new AvailableSize
 {
     Id     = drinkSize.Id.Value,
     Volume = drinkSize.Volume.Value,
     Name   = drinkSize.Name.Value,
     Price  = drinkSize.Price.Amount
 };
예제 #11
0
 public void StartCoffee(DrinkSize size, bool iced)
 {
     _coffeeDrink = new CoffeeDrink
     {
         Size = size,
         Iced = iced
     };
 }
예제 #12
0
 public Menu(string foodName, double price,
             bool isAvailable, DrinkSize sizeOfDrink)
 {
     FoodName    = foodName;
     Price       = price;
     IsAvailable = isAvailable;
     SizeOfDrink = sizeOfDrink;
 }
예제 #13
0
        public static Drink GetDrinkFromMenu(decimal dbId, DrinkSize drinkSize)
        {
            var drinkKey = Tuple.Create <decimal, DrinkSize>(dbId, drinkSize);

            if (DbIdDrinkDictionary.ContainsKey(drinkKey))
            {
                return(DbIdDrinkDictionary[drinkKey]);
            }
            //TODO:  Display error if drink is not in dictionary!
            return(new Drink());
        }
예제 #14
0
파일: Drink.cs 프로젝트: YungRAW/Starbucks
 public virtual void SetDrinkSize(DrinkSize drinkSize) // seteaza masura
 {
     try
     {
         this.size = drinkSize;
     }
     catch (MyCustomException exception)
     {
         throw new MyCustomException("Couldnt set drink size!");
     }
 }
예제 #15
0
        public static Drink MakeDrink(DrinkType type, DrinkFlavor flavor, DrinkSize size)
        {
            var delay = (flavor.GetHashCode() + size.GetHashCode() + (type.GetHashCode() * 2)) * 300;

            Thread.Sleep(delay);
            return(new Drink
            {
                Id = Guid.NewGuid(),
                Flavor = flavor,
                Size = size,
                Type = type
            });
        }
예제 #16
0
        public async Task <IActionResult> UpdateDrinkSize(DrinkSize drinkSize)
        {
            try
            {
                _drinkRepository.UpdateDrinkSize(drinkSize);
            }
            catch (DbUpdateConcurrencyException)
            {
                return(Json(new { success = false }));
            }

            var drink = _drinkRepository.GetDrinkById(drinkSize.DrinkId);
            var table = await this.RenderViewAsync("_ListDrinkSize", drink.DrinkSizes, true);

            return(Json(new { success = true, html = table }));
        }
예제 #17
0
        private static Decimal CalculateAmountAccordingTo(DrinkSize size)
        {
            switch (size)
            {
            case DrinkSize.Tall:
                return(3.25m);

            case DrinkSize.Grande:
                return(4.00m);

            case DrinkSize.Venti:
                return(4.75m);

            default:
                throw new InvalidOperationException(String.Format("Size '{0}' does not compute!", size));
            }
        }
예제 #18
0
        public void DrinkSizeGetPriceBySize()
        {
            double price1 = 3.0;
            double price2 = 5.0;
            double price3 = 7.50;

            DrinkSize drink = new DrinkSize
            {
                Small = 3.0,
                Large = 5.0,
                Ultra = 7.50,
            };

            Assert.Equal(price1, drink.getPriceBySize("small"));
            Assert.Equal(price2, drink.getPriceBySize("large"));
            Assert.Equal(price3, drink.getPriceBySize("ultra"));
        }
예제 #19
0
        public IActionResult UpdateDrinkSize(int?id, int drinkId)
        {
            var size = new DrinkSize();

            if (id == null)
            {
                size.DrinkId  = drinkId;
                size.IsActive = true;
            }
            else
            {
                size = _drinkRepository.GetSizeById(id.Value);
                if (size == null)
                {
                    return(NotFound());
                }
            }

            ViewBag.Units = _drinkRepository.DrinkUnits;
            return(PartialView(size));
        }
예제 #20
0
        public static Drink GetDrink(GuestItem oldGuestItem)
        {
            DrinkSize drinkSize = DrinkSize.JustOneSize;

            switch (oldGuestItem.SelectSizeID)
            {
            case 3:
                drinkSize = DrinkSize.Glass;
                break;

            case 6:
                drinkSize = DrinkSize.Bottle;
                break;

            case 1:
                drinkSize = DrinkSize.Pint;
                break;

            case 2:
                drinkSize = DrinkSize.Pitcher;
                break;

            default:
                drinkSize = DrinkSize.JustOneSize;
                break;
            }

            Drink drink    = MenuDrinks.GetDrinkFromMenu(oldGuestItem.ID, drinkSize);
            var   newdrink = drink.GetClone();

            newdrink.DbItemId         = oldGuestItem.ID;
            newdrink.WasSentToKitchen = oldGuestItem.OrderSent;
            newdrink.DbOrderId        = (int)oldGuestItem.OrderID;
            newdrink.ItemCount        = 1;
            return(newdrink);
        }
예제 #21
0
 private DrinkSizeDetails ToLastDrinkSizeDetails(DrinkSize size)
 {
     return(DrinkSizeDetails.Ordered(size.Id, size.Volume, size.Name));
 }
 public ReceivedFullPaymentView(String customerName, String drink, DrinkSize drinkSize)
 {
     CustomerName = customerName;
     Drink = drink;
     DrinkSize = drinkSize.ToString();
 }
예제 #23
0
 public Drink(string name, DrinkSize size)
 {
     Name = name;
     Size = size;
 }
예제 #24
0
파일: Drink.cs 프로젝트: YungRAW/Starbucks
 public Drink(string name, DrinkType type, DrinkSize drinkSize, bool hasStandardSize) : this(name, type)  // aici mostenim din base name si type si adaugam the rest
 {
     this.size            = size;
     this.hasStandardSize = hasStandardSize;
 }
예제 #25
0
 public CustomerRefusesToPayView(String customerName, Double amount, String drink, DrinkSize drinkSize)
 {
     CustomerName = customerName;
     Amount       = amount;
     Drink        = drink;
     DrinkSize    = drinkSize.ToString();
 }
예제 #26
0
 public DeliverOrderView(String drink, DrinkSize size)
 {
     Drink = drink;
     DrinkSize = size.ToString();
 }
 public OrderIsTrashedView(string drink, string customerName, DrinkSize size)
 {
     this.drink = drink;
     this.customerName = customerName;
     this.size = size;
 }
예제 #28
0
 public PrepareOrderView(String customerName, String drink, DrinkSize size)
 {
     CustomerName = customerName;
     Drink = drink;
     DrinkSize = size.ToString();
 }
예제 #29
0
        static public void AddOrder //adding order object both to stack and to queue
            (Queue <Order> ordersQueue, Stack <Order> ordersStack, Student orderer, CoffeeDrinks drink, DrinkSize cupsize)
        {
            Order order = new Order
            {
                Orderer = orderer,
                Drink   = drink,
                Size    = cupsize
            };

            Console.WriteLine($"{order.Orderer.FirstName} {order.Orderer.LastName} ordered a {order.Size} cup of {order.Drink}");
            ordersQueue.Enqueue(order);
            ordersStack.Push(order);
        }
예제 #30
0
 private OrderItem(Drink drink, DrinkSize drinkSize, Quantity count) =>
 (Drink, Size, Count) = (drink, drinkSize, count);
예제 #31
0
 public DeliverOrderView(String drink, DrinkSize size)
 {
     Drink     = drink;
     DrinkSize = size.ToString();
 }
예제 #32
0
 public Drink(String name, DrinkSize drinkSize)
 {
     this.name = name;
     this.size = drinkSize;
 }
예제 #33
0
 public OrderIsTrashedView(string drink, string customerName, DrinkSize size)
 {
     this.drink        = drink;
     this.customerName = customerName;
     this.size         = size;
 }
 public ReceivedFullPaymentView(String customerName, String drink, DrinkSize drinkSize)
 {
     CustomerName = customerName;
     Drink        = drink;
     DrinkSize    = drinkSize.ToString();
 }
예제 #35
0
 private OrderItem(Drink drink, DrinkSize drinkSize) =>
 (Drink, Size) = (drink, drinkSize);
예제 #36
0
 public Coffee(DrinkSize drinksize, decimal crustPrice, params Content[] contents)
 {
     DrinkSize = drinksize;
     Contents  = contents;
     Price     = crustPrice + contents.Sum(x => x.Price * x.Size);
 }
예제 #37
0
 public PrepareOrderView(String customerName, String drink, DrinkSize size)
 {
     CustomerName = customerName;
     Drink        = drink;
     DrinkSize    = size.ToString();
 }
예제 #38
0
 public DrinkOrder(bool iced, DrinkSize drinkSize, CoffeeBuilder drink)
 {
     Iced      = iced;
     DrinkSize = drinkSize;
     Drink     = drink;
 }