public ActionResult GetAllProductsWithDetails() { try { ProductBuyModel productBuyModel = null; // When the application gets loaded for the first time, then, it will retrieve from the mock data/database // but will get retrieved from the session, when the user has selected the product units and // wanted to check their total invoice amount if (HttpContext.Session.GetObject <ProductBuyModel>("productBuyModel") != null) { productBuyModel = (HttpContext.Session.GetObject <ProductBuyModel>("productBuyModel")); } else { productBuyModel = _productDetailsLogic.GetAllProductsWithDetails(); HttpContext.Session.SetObject("productBuyModel", productBuyModel); } return(View(productBuyModel)); } catch (Exception ex) { throw ex; } }
public ProductBuyModel CalculateTotalFromProductCart(List <ProductCartModel> productCartCollection, string productCouponApplied) { ProductBuyModel productBuyModel = new ProductBuyModel(); productBuyModel.productCartModel = productCartCollection; productBuyModel.productCouponModel = new ProductPromotionLogic().GetAllCouponsAvailable(); productBuyModel.productBuyTotalAmount = new ProductPromotionLogic().CalculationLogic(productCartCollection, productCouponApplied); return(productBuyModel); }
/// <summary> /// This method is responsible for creating the ProductBuyModel instance which will get returned /// to the home page after user goes for the checkout process by clicking on the CheckTotal button /// to see the total amount /// </summary> /// <param name="productCartCollection"></param> /// <param name="productCouponApplied"></param> /// <returns>ProductBuyModel object</returns> public ProductBuyModel CalculateTotalFromProductCart(List <ProductCartModel> productCartCollection, string productCouponApplied) { try { ProductBuyModel productBuyModel = new ProductBuyModel(); productBuyModel.productCartModel = productCartCollection; productBuyModel.productCouponModel = _productPromotionLogic.GetAllCouponsAvailable(productCouponApplied); productBuyModel.productBuyTotalAmount = productCartCollection.Where(item => item.productUnitcount > 0).Any() ? _productPromotionLogic.CalculationBasedOnCouponLogic(productCartCollection, productCouponApplied) : 0; return(productBuyModel); } catch (Exception ex) { throw ex; } }