//Simulates adding items to the inventory public async Task <ActionResult> testStock(string id) { var context = GlobalHost.ConnectionManager.GetHubContext <ChatHub>(); ApplicationState state = await ApplicationState.getApplicationState(); ViewBag.location = id; ViewBag.message = true; if (id == null) { ViewBag.message = false; return(View()); } try { string location = id; string bbsku = "Blue-Band"; string grsku = "Golden-Ray"; string kbsku = "Kiss-Bread"; string csku = "Crix"; ItemStocked fyzoStockBB = Helper.stockItem(state, system1, location, bbsku, 10); context.Clients.All.addNewMessageToPage("server", "stocked " + fyzoStockBB.sku + " " + fyzoStockBB.n); Item i = state.getItemStockFromLocation(location, bbsku); context.Clients.All.updateItemStock(location, "Blue Band", bbsku, i.quantity); ItemStocked fyzoStockGR = Helper.stockItem(state, system1, location, grsku, 100); context.Clients.All.addNewMessageToPage("server", "stocked " + fyzoStockGR.sku + " " + fyzoStockGR.n); i = state.getItemStockFromLocation(location, grsku); context.Clients.All.updateItemStock(location, "Golden Ray", grsku, i.quantity); ItemStocked fyzoStockKB = Helper.stockItem(state, system1, location, kbsku, 100); context.Clients.All.addNewMessageToPage("server", "stocked " + fyzoStockKB.sku + " " + fyzoStockKB.n); i = state.getItemStockFromLocation(location, kbsku); context.Clients.All.updateItemStock(location, "Kiss Bread", kbsku, i.quantity); ItemStocked fyzoStockC = Helper.stockItem(state, system1, location, csku, 100); context.Clients.All.addNewMessageToPage("server", "stocked " + fyzoStockC.sku + " " + fyzoStockC.n); i = state.getItemStockFromLocation(location, csku); context.Clients.All.updateItemStock(location, "Crix", csku, i.quantity); ViewBag.location = location; return(View()); } catch (Exception e) { ViewBag.message = false; return(View()); } }
public static ItemStocked stockItem(ApplicationState state, string system, string location, string sku, int n) { ItemStocked toStock = new ItemStocked() { location = location, sku = sku, n = n }; toStock.execute(state); EventLog.log(system, toStock); Console.WriteLine("Stocked {0} t {1} sku {2} ", toStock.location, toStock.n, toStock.sku); return(toStock); }
//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()); } }