Example #1
0
        public IActionResult ViewOrders(long locationId = 0, byte sort = 2)
        {
            IEnumerable <Order> temp = new List <Order>();

            if (locationId <= 0)
            {
                if (!long.TryParse(HttpContext.Session.GetString("_Store"), out locationId))
                {
                    ViewBag.Message = "Location not found";
                }
            }
            else
            {
                temp = _logic.FetchLocationOrders(locationId, sort);
                if (!temp.Any())
                {
                    ViewBag.Message = "Location not found";
                }
                else
                {
                    ViewBag.Summary = _logic.GetLocationOrderSummary(temp);
                }
            }
            return(View("ViewLocationOrders", ModelConvertor.OrdersToOrderViews(temp)));
        }
        public void Multiple_Orders_Saved_In_Location()
        {
            DbContextOptions <P1_DbContext> options = new DbContextOptionsBuilder <P1_DbContext>()
                                                      .UseInMemoryDatabase(databaseName: "Add_Writes_To_Db").Options;

            using (P1_DbContext context = new P1_DbContext(options))
            {
                context.Database.EnsureDeleted();
                context.Database.EnsureCreated();
                P1_Repo repo = new P1_Repo(context);
                DefaultAddItemsToContext(context);
                DefaultInitContext(context);
                repo.Init();
                repo.SubmitOrder(location_A, customer_A);
                repo.SubmitOrder(location_A, customer_A);
            }

            using (P1_DbContext context = new P1_DbContext(options))
            {
                P1_Repo    repo  = new P1_Repo(context);
                OrderLogic logic = new OrderLogic(repo, new HttpContextAccessor());
                Assert.AreEqual(2, logic.FetchLocationOrders(1).Count());
            }
        }