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); }
public Order(int number) { this.number = number; this.ice = null; this.cake = null; this.state = new AcceptOrder(); }
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); }
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; }
public ICake Main() { CarrotCakeMaker cakeMaker = new CarrotCakeMaker(); ICake myCake = cakeMaker.MakeCake(); return(myCake); // can now eat the delicious Carrot cake :) }
// 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; } } }
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); }
public CakeDecorator(ICake Cake) { m_DecoratedCake = Cake; }
public MeringuesOptions(ICake cake) { this.cake = cake; }
public MMsOption(ICake cake) { this.cake = cake; }
public FactoryMethodTest() { var factoryApp = new MainFactoryApp(); _myCake = factoryApp.Main(); }
public OrderController(ICake cake) { this.cake = cake; }
public CakeController(ICake cake, IMapper mapper) { this.cake = cake; this.mapper = mapper; }
public ChargeController(ICake cake) { this.cake = cake; }