Example #1
0
        static void Main(string[] args)
        {
            Fluent.PizzaHouse pizzeria = new PizzaHouse();

            Pizza pizza = pizzeria.MakePizza(new VegePizzaBuilder());

            pizza.Bake();

            pizzeria.MakePizza(new MeatPizza()).Bake();
        }
Example #2
0
        public void CheckIfPizzaIsCreatedAccordingToGivenBuilder()
        {
            PizzaHouse pizzeria = new PizzaHouse();

            Pizza pizza = pizzeria.MakePizza(new VegePizzaBuilder());

            pizza.Bake();

            pizzeria.MakePizza(new MeatPizza()).Bake();
            Assert.Pass();
        }
Example #3
0
        public void UpdatePizzaHouse(SettingEditDto dto)
        {
            UseDb(db =>
            {
                PizzaHouse entity = db.PizzaHouses.GetById(dto.PizzaHouseId);
                entity.Capacity   = dto.Capacity;
                dto.StartHour     = dto.StartHour % 24;
                dto.EndHour       = dto.EndHour % 24;
                entity.OpenTime   = TimeSpan.FromHours(dto.StartHour);
                entity.CloseTime  = TimeSpan.FromHours(dto.EndHour);
                db.PizzaHouses.Update(entity);

                var ams = db.IngredientAmounts.Query()
                          .Where(l => l.PizzaHouseId == dto.PizzaHouseId);

                foreach (var am in dto.IngState)
                {
                    var e = ams.FirstOrDefault(a => a.IngredientId == am.Id);
                    if (e == null)
                    {
                        e = new IngredientAmount
                        {
                            IngredientId = am.Id,
                            PizzaHouseId = dto.PizzaHouseId,
                            Quantity     = am.Quantity
                        };

                        db.IngredientAmounts.Create(e);
                    }
                    else
                    {
                        e.Quantity = am.Quantity;
                        db.IngredientAmounts.Update(e);
                    }
                }

                db.Save();
            });
        }