コード例 #1
0
        public async Task <CakeOrderViewModel> CalculateTotalPrice(CakeOrderViewModel model)
        {
            if (!string.IsNullOrEmpty(model.ShapeCode))
            {
                var initialData = await this.GetInitialData();

                List <string> toppings = new List <string>();
                if (model.Toppings != null)
                {
                    toppings = model.Toppings.Split(',').ToList();
                }

                ICake cake = initialData.CakeShapes.Where(x => x.Code.Trim() == model.ShapeCode.Trim()).FirstOrDefault();
                cake.Toppings    = initialData.Toppings.Where(w => toppings.Any(code => code == w.Code)).ToList();
                cake.Message     = model.Message;
                cake.Size        = model.Size;
                model.TotalPrice = cake.CalculatePrice();
            }
            else
            {
                model.TotalPrice = 0;
            }

            return(model);
        }
コード例 #2
0
ファイル: Order.cs プロジェクト: NastiaMikhaltsova/Kursash
 public Order(int number)
 {
     this.number = number;
     this.ice    = null;
     this.cake   = null;
     this.state  = new AcceptOrder();
 }
コード例 #3
0
        public async Task <bool> CreateCakeOrder(CakeOrderViewModel model, CancellationToken ct = default(CancellationToken))
        {
            Customer cus         = _customerRepository.GetByIdentityId(model.IdentityId);
            var      initialData = await this.GetInitialData();

            //calculate total price again
            List <string> toppings = model.Toppings.Split(',').ToList();
            ICake         cake     = initialData.CakeShapes.Where(x => x.Code.Trim() == model.ShapeCode.Trim()).FirstOrDefault();

            cake.Toppings    = initialData.Toppings.Where(w => toppings.Any(code => code.Trim() == w.Code.Trim())).ToList();
            cake.Message     = model.Message;
            cake.Size        = model.Size;
            model.TotalPrice = cake.CalculatePrice();
            CakeOrder order = new CakeOrder();

            order.CustomerId = cus.Id;
            order.Message    = model.Message;
            order.ShapeCode  = model.ShapeCode;
            order.Size       = model.Size;
            order.TotalPrice = model.TotalPrice;

            order = await _cakeOrderRepository.AddAsync(order);

            foreach (var topping in cake.Toppings)
            {
                Topping toppingEntity = new Topping();
                toppingEntity.CakeOrderId = order.Id;
                toppingEntity.Code        = topping.Code;
                await _toppingRepository.AddAsync(toppingEntity);
            }
            return(true);
        }
コード例 #4
0
    GameObject model; // instantiated prefab

    public WithTier(ICake Cake) : base(Cake)
    {
        GameObject prefab = Resources.Load <GameObject>(prefabPath);

        model = GameObject.Instantiate(prefab);
        model.transform.SetParent(GetGameObject().transform);
        model.transform.position += model.transform.parent.position;
    }
コード例 #5
0
        public ICake Main()
        {
            CarrotCakeMaker cakeMaker = new CarrotCakeMaker();

            ICake myCake = cakeMaker.MakeCake();

            return(myCake);
            // can now eat the delicious Carrot cake :)
        }
コード例 #6
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown("b"))
        {
            ICake Cake = new BasicCake(nextPos);
            currentCake = Cake;
            Debug.Log("Basic taste: " + Cake.GetTaste());
            nextPos += new Vector3(0, 0, 0);
        }

        if (Input.GetKeyDown("c"))
        {
            ICake Cake = new BasicCake(nextPos);
            Cake = new WithCream(Cake);
            currentCake = Cake;
            Debug.Log("With cream taste: " + Cake.GetTaste());
            nextPos += new Vector3(0, 0, 0);
        }

        if (Input.GetKeyDown("t"))
        {
            ICake Cake = new BasicCake(nextPos);
            Cake = new WithCream(new WithTier(Cake));
            currentCake = Cake;
            Debug.Log("New tier + cream taste: " + Cake.GetTaste());
            nextPos += new Vector3(0, 0, 0);
        }

		if (Input.GetKeyDown("p"))
        {
            ICake Cake = new BasicCake(nextPos);
            Cake = new WithTopper(new WithTier(new WithCream(Cake)));
            currentCake = Cake;
            Debug.Log("Topper+ Cream + new tier taste: " + Cake.GetTaste());
            nextPos += new Vector3(0, 0, 0);
        }
		if (Input.GetKeyDown("a"))
        {
            ICake Cake = new BasicCake(nextPos);
            Cake = new WithCandle(new WithTopper(new WithTier(new WithCream(Cake))));
            currentCake = Cake;
            Debug.Log("Candle+ Topper+ Cream + new tier taste: " + Cake.GetTaste());
            nextPos += new Vector3(0, 0, 0);
        }

        if (Input.GetKeyDown("d"))
        {
            if (currentCake != null)
            {
                GameObject.Destroy(currentCake.GetGameObject());
                currentCake = null;
            }
        }
    }
コード例 #7
0
        public void CreateCakeTest()
        {
            KievFactory leo = new KievFactory();
            ICake       max = leo.CreateCake();

            Assert.IsTrue(leo is KievFactory);
            Assert.IsTrue(max.Weight > 800);
            Assert.IsTrue(max is KievCake);
            Assert.IsTrue(max.Diameter == 32);
            Assert.AreNotSame(leo, max);
        }
コード例 #8
0
 public CakeDecorator(ICake Cake)
 {
     m_DecoratedCake = Cake;
 }
コード例 #9
0
 public MeringuesOptions(ICake cake)
 {
     this.cake = cake;
 }
コード例 #10
0
ファイル: MMsOption.cs プロジェクト: Kalle-kula/Patterns
 public MMsOption(ICake cake)
 {
     this.cake = cake;
 }
コード例 #11
0
        public FactoryMethodTest()
        {
            var factoryApp = new MainFactoryApp();

            _myCake = factoryApp.Main();
        }
コード例 #12
0
 public OrderController(ICake cake)
 {
     this.cake = cake;
 }
コード例 #13
0
ファイル: CakeController.cs プロジェクト: Adexandria/CakesAPI
 public CakeController(ICake cake, IMapper mapper)
 {
     this.cake   = cake;
     this.mapper = mapper;
 }
コード例 #14
0
 public ChargeController(ICake cake)
 {
     this.cake = cake;
 }