public async Task <IActionResult> OnGetAsync(string metaTitle, bool sentMessage = false) { if (metaTitle == null) { return(NotFound()); } if (sentMessage) { ViewData["Message"] = "دیدگاه شما با موفقیت ارسال و پس از تائید نمایش داده خواهد شد."; } Product = await _productService.GetProductByMetaTitle(metaTitle); Comments = await _commentService.GetAllCommentsByProductId(Product.ProductId); ConfigGroups = await _configGroupService.GetAllConfigGroupByCategoryId(Product.CategoryId); ConfigCharts = await _configChartService.GetAllConfigChartByCategoryId(Product.CategoryId); ConfigDetails = await _configDetailService.GetAllConfigDetailsByProductId(Product.ProductId); if (Product == null) { return(NotFound()); } await _productService.IncreaseVisit(Product.ProductId); return(Page()); }
public async Task <IActionResult> OnGetAsync(int productId, int categoryId) { ConfigDetails = await _configDetailService.GetAllConfigDetailsByProductId(productId); ConfigCharts = await _configChartService.GetAllConfigChartByCategoryId(categoryId); ConfigGroups = await _configGroupService.GetAllConfigGroupByCategoryId(categoryId); Product = await _productService.GetProductById(productId); ViewData["CategoryId"] = categoryId; ViewData["ProductId"] = productId; foreach (var chart in ConfigCharts) { if (!_configDetailService.AnyConfigDetailsByProductIdAndConfigChartId(productId, chart.Id)) { var configDetail = new ConfigDetail() { ProductId = productId, ConfigGroupId = chart.ConfigGroupId, ConfigChart = chart, ConfigChartId = chart.Id, Value = null }; await _configDetailService.AddConfigDetail(configDetail); } } return(Page()); }