コード例 #1
0
        public async Task <IActionResult> GetOrderDetailsOfOrder(string customerid, string orderId)
        {
            // retrive customers, orders and orderdetails of the order specified
            Customer curUser = new Customer();

            CustomersController.ConvertFromAppUserToCustomer(await _userManager.GetUserAsync(HttpContext.User), ref curUser);

            List <Order> orders = _context.Orders.Where(order => order.CustomerId == customerid)
                                  .OrderByDescending(order => order.OrderPlacedDateTime)
                                  .ToList();

            List <OrderDetail> orderDetails = _context.OrderDetails
                                              .Where(orderDetail => orderDetail.OrderId.ToString() == orderId)
                                              .OrderByDescending(orderdetail => orderdetail.BookId)
                                              .Include(od => od.book).ThenInclude(b => b.Category)
                                              .Include(b => b.book).ThenInclude(b => b.Supplier)
                                              .ToList();

            CustomersAndOrdersAndOrderDetailsViewModel vm = new CustomersAndOrdersAndOrderDetailsViewModel();

            vm.CustomerCurrent = curUser;
            vm.Orders          = orders;
            vm.OrderDetails    = orderDetails;

            vm.CustomerIdCurrent = customerid;
            vm.OrderIdCurrent    = orderId;

            return(View("Views/Profile/Index.cshtml", vm));
        }
コード例 #2
0
        public async Task <IActionResult> Index()
        {
            Customer curUser = new Customer();

            CustomersController.ConvertFromAppUserToCustomer(await _userManager.GetUserAsync(HttpContext.User), ref curUser);
            List <Order> orders = _context.Orders.Where(order => order.CustomerId == curUser.CustomerId)
                                  .OrderByDescending(order => order.OrderPlacedDateTime)
                                  .ToList();

            CustomersAndOrdersAndOrderDetailsViewModel vm = new CustomersAndOrdersAndOrderDetailsViewModel();

            vm.Orders            = orders;
            vm.CustomerCurrent   = curUser;
            vm.CustomerIdCurrent = curUser.CustomerId;

            return(View(vm));
        }