public ActionResult AdminEditor(int productVariantId) { FloorPackRecord record = _floorPackService.GetByProductVariantId(productVariantId); if (record == null) { record = new FloorPackRecord() { ProductVariantId = productVariantId, M2PerPack = 0 } } ; return(View("Nop.Plugin.Widgets.FloorPack.Views.AdminEditor", record)); } }
public ActionResult PublicInfo(string widgetZone) { PublicInfoModel model = new PublicInfoModel(); int productId = Convert.ToInt32(Request.RequestContext.RouteData.Values["productId"]); Product product = _productService.GetProductById(productId); ProductVariant productVariant = product.ProductVariants.FirstOrDefault(); FloorPackRecord record = _floorPackService.GetByProductVariantId(productVariant.Id); if (record == null || !record.M2PerPack.HasValue || record.M2PerPack.Value <= 0) { return(null); } model.M2PerPack = record.M2PerPack.Value; model.ProductVariantId = record.ProductVariantId; return(View("Nop.Plugin.Widgets.FloorPack.Views.PublicInfo", model)); }
public ActionResult Calculate(int productVariantId, decimal area) { ProductVariant productVariant = _productService.GetProductVariantById(productVariantId); FloorPackRecord floorPack = _floorPackService.GetByProductVariantId(productVariantId); int packCount = Convert.ToInt32(Math.Ceiling(area / floorPack.M2PerPack.Value)); decimal m2Count = packCount * floorPack.M2PerPack.Value; decimal unitPriceBase = productVariant.Price; string unitPriceFormatted = _priceFormatter.FormatPrice(unitPriceBase); decimal totalPriceBase = productVariant.Price * m2Count; string totalPriceFormatted = _priceFormatter.FormatPrice(totalPriceBase); return(Json(new { successful = true, calculationResult = string.Format("You Require {0} Packs ({1}m2) at {2} per m2", packCount, m2Count, unitPriceFormatted), totalPrice = string.Format("Total Price: {0}", totalPriceFormatted) })); }
public override void OnActionExecuted(ActionExecutedContext filterContext) { if (filterContext.Result is RedirectToRouteResult) { RedirectToRouteResult result = filterContext.Result as RedirectToRouteResult; IProductService productService = EngineContext.Current.Resolve <IProductService>(); //ProductVariant productVariant = null; int productVariantId = 0; if (filterContext.ActionDescriptor.ControllerDescriptor.ControllerType == typeof(ProductController) && filterContext.ActionDescriptor.ActionName.Equals("Create", StringComparison.InvariantCultureIgnoreCase)) { Product product = null; if (result.RouteValues.ContainsKey("Id")) { int productId = Convert.ToInt32(result.RouteValues["Id"]); product = productService.GetProductById(productId); } else { product = productService.GetAllProducts(true) .OrderByDescending(p => p.Id).FirstOrDefault(); } if (product != null) { productVariantId = product.ProductVariants.FirstOrDefault().Id; } //productVariant = product.ProductVariants.FirstOrDefault(); } else if (filterContext.ActionDescriptor.ControllerDescriptor.ControllerType == typeof(ProductVariantController)) { if (filterContext.ActionDescriptor.ActionName.Equals("Create", StringComparison.InvariantCultureIgnoreCase)) { if (result.RouteValues.ContainsKey("Controller") && result.RouteValues["Controller"].ToString() .Equals("Product", StringComparison.InvariantCultureIgnoreCase)) { int productId = Convert.ToInt32(result.RouteValues["Id"]); Product product = productService.GetProductById(productId); productVariantId = product.ProductVariants.OrderByDescending(pv => pv.Id) .FirstOrDefault().Id; //productVariant = product.ProductVariants.OrderByDescending(pv => pv.Id) // .FirstOrDefault(); } else { productVariantId = Convert.ToInt32(result.RouteValues["Id"]); //productVariant = productService.GetProductVariantById(productVariantId); } } else if (filterContext.ActionDescriptor.ActionName.Equals("Edit", StringComparison.InvariantCultureIgnoreCase)) { var requestRouteVales = filterContext.Controller.ControllerContext .RouteData.Values; productVariantId = Convert.ToInt32(requestRouteVales["Id"]); //productVariant = productService.GetProductVariantById(productVariantId); } } if (productVariantId > 0) { IFloorPackService floorPackService = EngineContext.Current .Resolve <IFloorPackService>(); FloorPackRecord record = floorPackService.GetByProductVariantId(productVariantId); NameValueCollection form = filterContext.HttpContext.Request.Form; decimal m2PerPack = 0; decimal.TryParse(form["M2PerPack"], out m2PerPack); if (record == null) { record = new FloorPackRecord(); } record.ProductVariantId = productVariantId; record.M2PerPack = m2PerPack; if (record.Id == 0) { floorPackService.Insert(record); } else { floorPackService.Update(record); } } } base.OnActionExecuted(filterContext); }
public void Delete(FloorPackRecord floorpack) { _floorPackRecordRepository.Delete(floorpack); }
public void Update(FloorPackRecord floorPack) { _floorPackRecordRepository.Update(floorPack); }
public void Insert(FloorPackRecord floorPack) { _floorPackRecordRepository.Insert(floorPack); }