Skip to content

Commit

Permalink
Added Place order control for Company Accounts in CartController
Browse files Browse the repository at this point in the history
  • Loading branch information
aliarmaganuygun committed Oct 19, 2024
1 parent c068b6b commit 02fff0f
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 4 deletions.
21 changes: 17 additions & 4 deletions BulkyWeb/Areas/Customer/Controllers/CartController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,17 +81,18 @@ public IActionResult SummaryPOST()

ShoppingCartVM.OrderHeader.OrderDate = System.DateTime.Now;
ShoppingCartVM.OrderHeader.ApplicationUserId = userId;
ShoppingCartVM.OrderHeader.ApplicationUser = _unitOfWork.ApplicationUser.Get(u => u.Id == userId);

ApplicationUser applicationUser = _unitOfWork.ApplicationUser.Get(u => u.Id == userId);

foreach (var cart in ShoppingCartVM.ShoppingCartList)
{
cart.Price = GetPriceBasedOnQuantity(cart);
ShoppingCartVM.OrderHeader.OrderTotal += (cart.Price * cart.Count);
}

if (ShoppingCartVM.OrderHeader.ApplicationUser.CompanyId.GetValueOrDefault() == 0)
if (applicationUser.CompanyId.GetValueOrDefault() == 0)
{
//it is a regular customer account and we need to capture payment
//it is a regular customer
ShoppingCartVM.OrderHeader.PaymentStatus = SD.PaymentStatusPending;
ShoppingCartVM.OrderHeader.OrderStatus = SD.StatusPending;
}
Expand All @@ -117,7 +118,19 @@ public IActionResult SummaryPOST()
_unitOfWork.OrderDetail.Add(orderDetail);
_unitOfWork.Save();
}
return View(ShoppingCartVM);
if (applicationUser.CompanyId.GetValueOrDefault() == 0)
{
//it is a regular customer account and we need to capture payment
//stripe logic

}

return RedirectToAction(nameof(OrderConfirmation), new {id= ShoppingCartVM.OrderHeader.Id});
}

public IActionResult OrderConfirmation(int id)
{
return View(id);
}

private double GetPriceBasedOnQuantity(ShoppingCart shoppingCart)
Expand Down
13 changes: 13 additions & 0 deletions BulkyWeb/Areas/Customer/Views/Cart/OrderConfirmation.cshtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
@model int

<div class="container row pt-4">
<div class="col-12 text-center">
<h1 class="text-primary text-center">Order Placed Succesfully!</h1>
Your Order Number is: <strong>@Model</strong> <br /><br />
<img src="/images/lawn_leaf.jpg" style="width:65%" />
</div>
<div class="col-12 text-center" style="color:maroon">
<br />
Your order has been placed succesfully! <br />
</div>
</div>
Binary file added BulkyWeb/wwwroot/images/book.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added BulkyWeb/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 02fff0f

Please sign in to comment.