Esempio n. 1
0
        public UnitResult <CoffeeMachineEntity> Execute(int coffeeGrams, int waterMl)
        {
            if (coffeeMachine.IsClean)
            {
                coffeeMachine.SetCoffee(coffeeGrams);
                coffeeMachine.GetWater(waterMl);
            }

            bool ranSuccessfully = false;

            if (coffeeMachine.IsReadyForEspresso())
            {
                ICoffeeMachineService coffeeMachineService = new CoffeeMachineService();    //external service
                ranSuccessfully = coffeeMachineService.SetCoffee(coffeeMachine.CoffeeQty);
                ranSuccessfully = ranSuccessfully && coffeeMachineService.GetWater(coffeeMachine.WaterQty);
                ranSuccessfully = ranSuccessfully && coffeeMachineService.Run();
            }

            UnitResult <CoffeeMachineEntity> operationResult = new UnitResult <CoffeeMachineEntity>
            {
                IsSuccessful = ranSuccessfully,
                Value        = coffeeMachine
            };

            return(operationResult);
        }
Esempio n. 2
0
        public UnitResult <CoffeeMachineEntity> Execute(int blastSeconds, int waterMl)
        {
            coffeeMachine.GetWater(waterMl);
            coffeeMachine.SteamBlast(blastSeconds);

            bool isSuccessful = false;

            if (coffeeMachine.IsReadyForSteamBlast())
            {
                ICoffeeMachineService coffeeMachineService = new CoffeeMachineService();

                isSuccessful = coffeeMachineService.GetWater(coffeeMachine.WaterQty);
                isSuccessful = isSuccessful && coffeeMachineService.SteamBlast(blastSeconds);
            }

            var operationResult = new UnitResult <CoffeeMachineEntity>
            {
                IsSuccessful = isSuccessful,
                Value        = coffeeMachine
            };

            return(operationResult);
        }
Esempio n. 3
0
 public CoffeeMachineWork()
 {
     context     = new ApplicationDBContext();
     menuService = new CoffeeMachineService(context);
 }