Skip to content

Commit

Permalink
Section 10 - Order Confirmation
Browse files Browse the repository at this point in the history
  • Loading branch information
bhrugen committed Sep 26, 2021
1 parent f4155e6 commit 441fa31
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
14 changes: 13 additions & 1 deletion BulkyBookWeb/Areas/Customer/Controllers/CartController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using Microsoft.AspNetCore.Mvc;
using Stripe.Checkout;
using System.Collections.Generic;
using System.Linq;
using System.Security.Claims;

namespace BulkyBookWeb.Areas.Customer.Controllers
Expand Down Expand Up @@ -164,8 +165,19 @@ public IActionResult SummaryPOST()
public IActionResult OrderConfirmation(int id)
{
OrderHeader orderHeader = _unitOfWork.OrderHeader.GetFirstOrDefault(u => u.Id == id);

var service = new SessionService();
Session session = service.Get(orderHeader.SessionId);
//check the stripe status
if (session.PaymentStatus.ToLower() == "paid")
{
_unitOfWork.OrderHeader.UpdateStatus(id, SD.StatusApproved, SD.PaymentStatusApproved);
_unitOfWork.Save();
}
List<ShoppingCart> shoppingCarts = _unitOfWork.ShoppingCart.GetAll(u => u.ApplicationUserId ==
orderHeader.ApplicationUserId).ToList();
_unitOfWork.ShoppingCart.RemoveRange(shoppingCarts);
_unitOfWork.Save();
return View(id);
}

public IActionResult Plus(int cartId)
Expand Down
15 changes: 15 additions & 0 deletions BulkyBookWeb/Areas/Customer/Views/Cart/OrderConfirmation.cshtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
@model int

<div class="container row">
<div class="col-12 text-center">
<h1 class="text-primary text-center">Order Placed Successfully!</h1>
Your Order Number is : @Model <br /><br />
<img src="~/images/lawn_leaf.jpg" width="65%" />
</div>
<div class="col-12 text-center" style="color:maroon">
<br />
Your order has been placed successfully! <br />

</div>
</div>

Binary file added BulkyBookWeb/wwwroot/images/lawn_leaf.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 441fa31

Please sign in to comment.