Ejemplo n.º 1
0
        public async Task <ActionResult> PaidCart(Order orderInformation)
        {
            if (ModelState.IsValid)
            {
                var userId = User.Identity.GetUserId();

                var newOrder = shoppingCartManager.CreateOrder(orderInformation, userId);

                var user = await UserManager.FindByIdAsync(userId);

                TryUpdateModel(user.UserInformation);

                await UserManager.UpdateAsync(user);

                shoppingCartManager.ClearCart();

                //var order = db.Orders.Include("OrderItems").Include("OrderItems.Product").SingleOrDefault(a => a.OrderID == newOrder.OrderID);
                var order = db.Orders.Include("OrderItems").SingleOrDefault(a => a.OrderID == newOrder.OrderID);

                // string url = Url.Action("SendConfirmationEmail", "Manage", new { orderID = newOrder.OrderID, surname = newOrder.Surname }, Request.Url.Scheme);

                ///BackgroundJob.Enqueue(() => Helpers.CallUrl(url));
                this.mailService.SendOrderConfirmationEmail(order);

                return(RedirectToAction("PaymentPage", order));
            }
            else
            {
                return(View(orderInformation));
            }
        }
Ejemplo n.º 2
0
        public JsonResult ClearCart()
        {
            var session = HttpContext.Session;

            return(Json(ShoppingCartManager.ClearCart(session) ?? new object()));
        }