示例#1
0
        public CountServiceTest()
        {
            countService = new CountService();

            GuestOrder guestOrder = new GuestOrder()
            {
                IsGoingByBus = true,
                IsVegetarian = true
            };

            GuestResponse guestResponse1 = new GuestResponse()
            {
                Name       = "Ala",
                WillAttend = true,
                GuestOrder = guestOrder
            };

            Repository.AddResponse(guestResponse1);



            GuestOrder guestOrder2 = new GuestOrder()
            {
                IsGoingByBus = true,
                IsVegetarian = false
            };
            GuestResponse guestResponse2 = new GuestResponse()
            {
                Name       = "Ala",
                WillAttend = true,
                GuestOrder = guestOrder2
            };

            Repository.AddResponse(guestResponse2);
        }
        public IActionResult MarkShipped(int guestOrderID)
        {
            GuestOrder guestOrder = repository.GuestOrders
                                    .FirstOrDefault(o => o.GuestOrderID == guestOrderID);

            if (guestOrder != null)
            {
                guestOrder.Shipped = true;
                repository.SaveOrder(guestOrder);
            }
            return(RedirectToAction(nameof(List)));
        }
 public IActionResult Checkout(GuestOrder guestOrder)
 {
     if (cart.Lines.Count() == 0)
     {
         ModelState.AddModelError("", "Sorry, your cart is empty!");
     }
     if (ModelState.IsValid)
     {
         guestOrder.Lines = cart.Lines.ToArray();
         repository.SaveOrder(guestOrder);
         return(RedirectToAction(nameof(Completed)));
     }
     else
     {
         return(View(guestOrder));
     }
 }