public void Multiple_Orders_Saved_In_Customer()
        {
            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);
                context.SaveChanges();
            }

            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.FetchCustomerOrders(1, customer_A).Count());
            }
        }
Example #2
0
 public IActionResult ViewOrders(byte sort = 2)
 {
     try
     {
         IEnumerable <Order> temp = _logic.FetchCustomerOrders(sort);
         ViewBag.Summary = _logic.GetCustomerOrderSummary(temp);
         return(View("ViewCustomerOrders", ModelConvertor.OrdersToOrderViews(temp)));
     }
     catch (ArgumentNullException e)
     {
         _logger.LogError(e.ToString());
         ViewBag.Message = "We encountered an error. Please retry.";
         _logic.ResetCache();
         return(View("Index"));
     }
 }