Exemplo n.º 1
0
        public static PriceSetted setPrice(ApplicationState state, string system, string location, string sku, double cp, double sp)
        {
            PriceSetted ps = new PriceSetted()
            {
                location = location,
                sku      = sku,
                cp       = cp,
                sp       = sp
            };

            ps.execute(state);
            EventLog.log(system, ps);
            Console.WriteLine("{0} {1} cp {2} sp {3}", ps.location, ps.sku, ps.cp, ps.sp);
            return(ps);
        }
        //Simuluates the population of inventory meta data
        public async Task <ActionResult> TestLoadAsync(string id)
        {
            ViewBag.location = id;
            ViewBag.message  = true;
            ViewBag.loaded   = false;

            if (id == null)
            {
                ViewBag.message = false;
                return(View());
            }

            try
            {
                string           location = id;
                var              context  = GlobalHost.ConnectionManager.GetHubContext <ChatHub>();
                ApplicationState state    = await ApplicationState.getApplicationState();

                ItemCreated fyzoBB = Helper.createItem(state, system1, location, "Blue Band");
                context.Clients.All.addNewMessageToPage("server", location + " create " + fyzoBB.sku);

                ItemCreated fyzoGR = Helper.createItem(state, system1, location, "Golden Ray");
                context.Clients.All.addNewMessageToPage("server", location + " create " + fyzoGR.sku);

                ItemCreated fyzoKB = Helper.createItem(state, system1, location, "Kiss Bread");
                context.Clients.All.addNewMessageToPage("server", location + " create " + fyzoKB.sku);

                ItemCreated fyzoC = Helper.createItem(state, system1, location, "Crix");
                context.Clients.All.addNewMessageToPage("server", location + " create " + fyzoC.sku);

                ItemStocked fyzoStockBB = Helper.stockItem(state, system1, fyzoBB.location, fyzoBB.sku, 10);
                context.Clients.All.addNewMessageToPage("server", location + " stocked " + fyzoStockBB.sku + " " + fyzoStockBB.n);

                ItemStocked fyzoStockGR = Helper.stockItem(state, system1, fyzoGR.location, fyzoGR.sku, 100);
                context.Clients.All.addNewMessageToPage("server", location + " stocked " + fyzoStockGR.sku + " " + fyzoStockGR.n);

                ItemStocked fyzoStockKB = Helper.stockItem(state, system1, fyzoKB.location, fyzoKB.sku, 100);
                context.Clients.All.addNewMessageToPage("server", location + " stocked " + fyzoStockKB.sku + " " + fyzoStockKB.n);

                ItemStocked fyzoStockC = Helper.stockItem(state, system1, fyzoC.location, fyzoC.sku, 100);
                context.Clients.All.addNewMessageToPage("server", location + " stocked " + fyzoStockC.sku + " " + fyzoStockC.n);


                PriceSetted fyzoBBPrice = Helper.setPrice(state, system1, fyzoBB.location, fyzoBB.sku, 10.99, 15.99);
                context.Clients.All.addNewMessageToPage("server", location + " set price " + fyzoBBPrice.sku + " " + fyzoBBPrice.cp + " " + fyzoBBPrice.sp);

                PriceSetted fyzoGRPrice = Helper.setPrice(state, system1, fyzoGR.location, fyzoGR.sku, 5.99, 9.99);
                context.Clients.All.addNewMessageToPage("server", location + " set price " + fyzoGRPrice.sku + " " + fyzoGRPrice.cp + " " + fyzoGRPrice.sp);

                PriceSetted fyzoKBPrice = Helper.setPrice(state, system1, fyzoKB.location, fyzoKB.sku, 6.99, 12.99);
                context.Clients.All.addNewMessageToPage("server", location + " set price " + fyzoKBPrice.sku + " " + fyzoKBPrice.cp + " " + fyzoKBPrice.sp);

                PriceSetted fyzoCPrice = Helper.setPrice(state, system1, fyzoC.location, fyzoC.sku, 8.99, 10.99);
                context.Clients.All.addNewMessageToPage("server", location + " set price " + fyzoCPrice.sku + " " + fyzoCPrice.cp + " " + fyzoCPrice.sp);

                return(View());
            }
            catch (Exception e)
            {
                ViewBag.loaded  = true;
                ViewBag.message = false;
                return(View());
            }
        }