private Task <bool> InitialiseReadModel() { return(Task.Run( async() => { try { var items = await orderServiceInvoker.CallService(service => service.GetAllStoreItemsAsync()); StoreItems.AddRange(items.Select(x => new StoreItemViewModel(x))); HasItems = StoreItems.Any(); return true; } catch (Exception e) { return false; } })); }
// On program startup add static shop data to lists public ActionResult CreateIndex() { //check if store already has items --> For when user refreshes page if (StoreItems.Count() == 0) { //Create Diffrent concole Models //PS4 playstations.Add(new Playstation(1, "Playstation 1", "Reto Ps with Gret finish", "2001_01PS1", 845.37, 10, "~/Content/Images/PS/Ps1.png", new DateTime(2001, 1, 18).Date, "3 working days", "PSN120934", "5")); playstations.Add(new Playstation(2, "Playstation 2", "Second Gen console with 8mb Video cards", "2006_01PS2", 1000.50, 8, "~/Content/Images/PS/Ps2.png", new DateTime(2004, 1, 18).Date, "6 working days", "PSN120935", "6.5")); playstations.Add(new Playstation(3, "Playstation 3", "Redesigned modern console with Dualshock 4 bluetooth controllers", "2011_01PS3", 1980.00, 10, "~/Content/Images/PS/Ps3.png", new DateTime(2011, 1, 18).Date, "4 working days", "PSN120936", "8.5")); playstations.Add(new Playstation(4, "Playstation 4", "Latest gen console with 4k graphics cards", "2016_01PS4", 4500.00, 3, "~/Content/Images/PS/Ps4.png", new DateTime(2015, 1, 18).Date, "2 working days", "PSN120934", "9.8")); //add mplaystations to store list StoreItems.AddRange(playstations); //Xbox xboxs.Add(new Xbox(1, "xbox 360", "Intel based i2 pc inspired console", "xb_360_01", 656.89, 10, "~/Content/Images/XB/box1.png", new DateTime(2001, 1, 26).Date, "3 working days", "xb36000", "AAA")); xboxs.Add(new Xbox(2, "xbox 730", "Upgraded Intel chipped game centric", "xb_360_2019", 1290.00, 10, "~/Content/Images/XB/box2.png", new DateTime(2005, 1, 14).Date, "2 working days", "xb36000", "AA3")); xboxs.Add(new Xbox(3, "xbox oneS", "2019 white finished console", "xb_360_2222", 1890.00, 9, "~/Content/Images/XB/box3.png", new DateTime(2017, 1, 13).Date, "1 working days", "xb36000", "AA_IO")); xboxs.Add(new Xbox(4, "xbox Prime", "Maxed out Prime version", "xb_360_2343", 3567.00, 4, "~/Content/Images/XB/box4.png", new DateTime(2016, 1, 12).Date, "6 working days", "xb36000", "AAB")); //add mplaystations to store list StoreItems.AddRange(xboxs); //Nintendo ntendos.Add(new Nintendo(1, "Wii", "white 12' with blue strobe led", "wii_0707", 850.00, 10, "~/Content/Images/NT/wii1.png", new DateTime(2003, 1, 20).Date, "2 working days", "switch_P23", "medium")); ntendos.Add(new Nintendo(2, "Game", "GameV console with chrome finish", "wii_888", 1500.00, 10, "~/Content/Images/NT/wii2.png", new DateTime(206, 1, 21).Date, "2 working days", "switch_P23", "small")); ntendos.Add(new Nintendo(3, "DS Lite ", "dual screen padded device", "wii_0ds900", 2400.00, 3, "~/Content/Images/NT/wii3.png", new DateTime(2010, 1, 24).Date, "3 working days", "switch_P23", "large")); ntendos.Add(new Nintendo(4, "SwitchT", "white 12' with blue strobe led", "wii_swtch_09", 3000.00, 1, "~/Content/Images/NT/wii4.png", new DateTime(2019, 1, 23).Date, "1 working days", "switch_P23", "medium")); //add mplaystations to store list StoreItems.AddRange(ntendos); //Redirect to home on successful creation return(RedirectToAction("Index", "Home")); } else { //if objects already exist in shop the redirect to home return(RedirectToAction("Index", "Home")); } }