Ejemplo n.º 1
0
        public async Task <ActionResult> ConfirmOrder()
        {
            //update status order
            //_orderService.UpdateStatus(int.Parse(result.order_code));
            //_orderService.Save();
            var billSession = HttpContext.Session.Get <BillViewModel>(CommonConstants.BillSession);

            await _billService.UpdateStatus(billSession.Id, BillStatus.InProgress);

            foreach (var bill in billSession.BillDetails)
            {
                await _quantityService.UpdateQuantityProduct(bill.ProductId, bill.Quantity);
            }

            var announcement = new AnnouncementViewModel()
            {
                Content     = $"Bạn có một đơn hàng từ {billSession.CustomerName}",
                DateCreated = DateTime.Now,
                Status      = Status.Active,
                Title       = "New Order",
                UserId      = User.GetUserId(),
                Id          = Guid.NewGuid().ToString()
            };
            //  await _hubContext.Clients.Client("").SendAsync("ReceiveMessage", announcement);
            await _hubContext.Clients.All.SendAsync("ReceiveMessage", announcement);

            ViewBag.IsSuccess = true;
            ViewBag.Result    = "Thanh toán thành công. Chúng tôi sẽ liên hệ lại sớm nhất.";

            HttpContext.Session.Set(CommonConstants.CartSession, new List <ShoppingCartViewModel>());
            return(View(billSession));
        }