public IActionResult Index() { ViewData["TrolleyItems"] = TrolleyProxy.GetInstance().GetCurrentNumberOfItems(HttpContext.Session.Id.ToString()); var inventory = InventoryProxy.GetInstance().GetInventory(); var storeModel = new StoreViewModel(); foreach (var key in inventory.Keys) { storeModel.AddWineToDisplay(inventory[key]); } return(View(storeModel)); }
private void BuyEnergy(string itemOffer) { mLevel.SendNotification(GameFacade.HIDE_POPUP); InventoryProxy inventoryProxy = GameFacade.Instance.RetrieveProxy <InventoryProxy>(); inventoryProxy.PurchaseRequest(itemOffer, InventoryGlobals.CASH, delegate(Message message) { XmlDocument xmlResponse = new XmlDocument(); xmlResponse.LoadXml((string)message.Data[0]); inventoryProxy.HidePurchaseModel(); XmlNode errorCode = xmlResponse.SelectSingleNode("Response/errors/error/@code"); if (errorCode == null) { List <object> args = new List <object>(); args.Add(FashionGameTranslation.SUCCESS); args.Add(FashionGameTranslation.PURCHASE_COMPLETE); Hangout.Shared.Action okcb = delegate() { mLevel.SendNotification(GameFacade.HIDE_POPUP); FashionGameGui gui = GameFacade.Instance.RetrieveMediator <FashionGameGui>(); gui.EnergyRefilled(); mLevel.Gameplay.StartWaves(); }; args.Add(okcb); args.Add(FashionGameTranslation.PLAY_LEVEL); GameFacade.Instance.SendNotification(GameFacade.SHOW_DIALOG, args); } else if (int.Parse(errorCode.InnerText) == 270007) // Attempt to go below account minimum balance. { // Leave the minigame completely and go to the webpage for buying more cash BuyCoinUtility.GoToBuyCashPage ( FashionGameTranslation.NOT_ENOUGH_CASH_TITLE, FashionGameTranslation.NOT_ENOUGH_CASH_MESSAGE, delegate(string jsResult) { ShowOutOfEnergyGui(); }, ShowOutOfEnergyGui ); } }); }
private void GetMoreEnergyPressed() { mOutOfEnergyGui.Dispose(); InventoryProxy inventoryProxy = GameFacade.Instance.RetrieveProxy <InventoryProxy>(); inventoryProxy.GetStoreInventory ( InventoryGlobals.ENERGY_STORE_CASH, ItemType.ENERGY_REFILL, 0, 1, delegate(Message buyEnergyResponseMessage) { XmlDocument xml = new XmlDocument(); xml.LoadXml((string)buyEnergyResponseMessage.Data[0]); List <object> args = new List <object>(); args.Add(FashionGameTranslation.BUY_ENERGY); args.Add ( String.Format ( FashionGameTranslation.REFILL_ENERGY_MESSAGE, (int)float.Parse(xml.SelectSingleNode // stupid floor action ( "Response/store/itemOffers/itemOffer/price/money/@amount" ).InnerText) ) ); Hangout.Shared.Action okcb = delegate() { BuyEnergy(xml.SelectSingleNode("Response/store/itemOffers/itemOffer/@id").InnerText); }; Hangout.Shared.Action cancelcb = ShowOutOfEnergyGui; args.Add(okcb); args.Add(cancelcb); args.Add(FashionGameTranslation.BUY); args.Add(FashionGameTranslation.CANCEL); GameFacade.Instance.SendNotification(GameFacade.SHOW_CONFIRM, args); } ); }
public IActionResult Index() { ViewData["TrolleyItems"] = TrolleyProxy.GetInstance().GetCurrentNumberOfItems(HttpContext.Session.Id.ToString()); var trolleyModel = new TrolleyViewModel(); var trolleyItems = TrolleyProxy.GetInstance().GetCurrentTrolleyItems(HttpContext.Session.Id); Dictionary <string, int> preDict = new Dictionary <string, int>(); foreach (var item in trolleyItems) { if (string.IsNullOrWhiteSpace(item)) { continue; } if (preDict.ContainsKey(item)) { preDict[item]++; } else { preDict.Add(item, 1); } } double total = 0.0; foreach (var key in preDict.Keys) { var wine = InventoryProxy.GetInstance().GetInventoryItem(key); trolleyModel.AddTrolleyItemToDisplay(wine, preDict[key]); total = total + (wine.WinePrice * preDict[key]); } ViewData["Total"] = String.Format("{0:N2}", total); return(View(trolleyModel)); }
public IActionResult Order(string EMail) { var trolleyModel = new TrolleyViewModel(); ViewData["CustomerEMail"] = EMail; ViewData["OrderResult"] = "Your order has gone through! We will confirm over e-mail shortly."; ViewData["OrderBool"] = true; ViewData["TrolleyItems"] = TrolleyProxy.GetInstance().GetCurrentNumberOfItems(HttpContext.Session.Id.ToString()); if (string.IsNullOrWhiteSpace(EMail)) { ViewData["OrderResult"] = "E-Mail address not valid. Please try again."; ViewData["OrderBool"] = false; } else { if (!EMail.Contains('@') || !EMail.Contains('.')) { ViewData["OrderResult"] = "E-Mail address not valid. Please try again."; ViewData["OrderBool"] = false; } } var trolleyItems = TrolleyProxy.GetInstance().GetCurrentTrolleyItems(HttpContext.Session.Id); Dictionary <string, int> preDict = new Dictionary <string, int>(); foreach (var item in trolleyItems) { if (string.IsNullOrWhiteSpace(item)) { continue; } if (preDict.ContainsKey(item)) { preDict[item]++; } else { preDict.Add(item, 1); } } double total = 0.0; foreach (var key in preDict.Keys) { var wine = InventoryProxy.GetInstance().GetInventoryItem(key); trolleyModel.AddTrolleyItemToDisplay(wine, preDict[key]); total = total + (wine.WinePrice * preDict[key]); } ViewData["Total"] = String.Format("{0:N2}", total); if ((bool)ViewData["OrderBool"] == false) { return(View(trolleyModel)); } var orderResult = PurchaseProxy.GetInstance().TryOrder(HttpContext.Session.Id, EMail); var orderArray = orderResult.Split(";"); if (orderArray[0].Equals("Success")) { ViewData["OrderBool"] = true; ViewData["OrderResult"] = orderArray[1]; ViewData["TrolleyItems"] = "0"; } else { ViewData["OrderBool"] = false; ViewData["OrderResult"] = orderArray[1]; } return(View(trolleyModel)); }