From 6e7c40a34758828a03715afa7b693a5c8653ead9 Mon Sep 17 00:00:00 2001 From: malik masis Date: Wed, 27 Jul 2022 19:05:55 +0300 Subject: [PATCH 1/8] Added ProductDetail page --- .../Pages/ProductDetail.cshtml | 65 +++++++++++++++++++ .../Pages/ProductDetail.cshtml.cs | 38 +++++++++++ 2 files changed, 103 insertions(+) create mode 100644 apps/public-web/src/EShopOnAbp.PublicWeb/Pages/ProductDetail.cshtml create mode 100644 apps/public-web/src/EShopOnAbp.PublicWeb/Pages/ProductDetail.cshtml.cs diff --git a/apps/public-web/src/EShopOnAbp.PublicWeb/Pages/ProductDetail.cshtml b/apps/public-web/src/EShopOnAbp.PublicWeb/Pages/ProductDetail.cshtml new file mode 100644 index 00000000..5656dc03 --- /dev/null +++ b/apps/public-web/src/EShopOnAbp.PublicWeb/Pages/ProductDetail.cshtml @@ -0,0 +1,65 @@ +@page "{id:guid}" +@using EShopOnAbp.Localization +@using Microsoft.Extensions.Localization +@using System.Globalization +@using Microsoft.Extensions.Options +@using Volo.Abp.Http.Client +@model EShopOnAbp.PublicWeb.Pages.ProductDetailModel +@inject IStringLocalizer L +@inject IOptions options + +@{ + string pageHeader = Model.Product.Name; +} + +@section styles{ + +} + +@section scripts { + + +} + +@if (Model.HasRemoteServiceError) +{ + pageHeader = L["CatalogServiceNotAvailable"]; +} + +
+
+
+

@pageHeader

+
+ @{ + var product = Model.Product; + var productPrice = product.Price.ToString("C", new CultureInfo("en-US")); + string productImage = !product.ImageName.IsNullOrEmpty() ? $"{options.Value.RemoteServices.Default.BaseUrl}product-images/{product.ImageName}" : $"{options.Value.RemoteServices.Default.BaseUrl}product-images/@product.ImageName"; + string buyText = L["Index:AddToBasket"]; +
+
+
+
@product.Name
+ @product.Code - @L["StockCount"]: @product.StockCount +
+
+ +
+ @if (product.StockCount > 0) + { + + } + else + { + + } +
+ @productPrice +
+
+
+ } +
+
+
+
\ No newline at end of file diff --git a/apps/public-web/src/EShopOnAbp.PublicWeb/Pages/ProductDetail.cshtml.cs b/apps/public-web/src/EShopOnAbp.PublicWeb/Pages/ProductDetail.cshtml.cs new file mode 100644 index 00000000..220cfeff --- /dev/null +++ b/apps/public-web/src/EShopOnAbp.PublicWeb/Pages/ProductDetail.cshtml.cs @@ -0,0 +1,38 @@ +using EShopOnAbp.CatalogService.Products; +using Microsoft.AspNetCore.Mvc; +using System; +using System.Threading.Tasks; +using Volo.Abp.AspNetCore.Mvc.UI.RazorPages; + +namespace EShopOnAbp.PublicWeb.Pages +{ + public class ProductDetailModel : AbpPageModel + { + [BindProperty(SupportsGet = true)] + public int OrderNo { get; set; } + + public ProductDto Product { get; private set; } + public bool HasRemoteServiceError { get; set; } = false; + private readonly IPublicProductAppService _productAppService; + + + public ProductDetailModel(IPublicProductAppService productAppService) + { + _productAppService = productAppService; + } + + public async Task OnGet(Guid id) + { + try + { + Product = await _productAppService.GetAsync(id); + } + catch (Exception e) + { + Product = new ProductDto(); + HasRemoteServiceError = true; + Console.WriteLine(e); + } + } + } +} \ No newline at end of file From de2707393597826db3ee2903b38ab763605e24e9 Mon Sep 17 00:00:00 2001 From: malik masis Date: Wed, 27 Jul 2022 19:06:09 +0300 Subject: [PATCH 2/8] Added routing url --- .../EShopOnAbp.PublicWeb/Pages/Index.cshtml | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/apps/public-web/src/EShopOnAbp.PublicWeb/Pages/Index.cshtml b/apps/public-web/src/EShopOnAbp.PublicWeb/Pages/Index.cshtml index e19737e6..4e0b6485 100644 --- a/apps/public-web/src/EShopOnAbp.PublicWeb/Pages/Index.cshtml +++ b/apps/public-web/src/EShopOnAbp.PublicWeb/Pages/Index.cshtml @@ -14,12 +14,12 @@ } @section styles{ - + } @section scripts { - - + + } @if (Model.HasRemoteServiceError) @@ -44,13 +44,15 @@ string productImage = !product.ImageName.IsNullOrEmpty() ? $"{options.Value.RemoteServices.Default.BaseUrl}product-images/{product.ImageName}" : $"{options.Value.RemoteServices.Default.BaseUrl}product-images/@product.ImageName"; string buyText = L["Index:AddToBasket"];
-
-
-
@product.Name
- @product.Code - @L["StockCount"]: @product.StockCount + +
+
+
@product.Name
+ @product.Code - @L["StockCount"]: @product.StockCount +
-
- + +
@if (product.StockCount > 0) { From a6de196e22aed6f2d568cf7ad9c327e8707e6b48 Mon Sep 17 00:00:00 2001 From: malik masis Date: Wed, 27 Jul 2022 19:06:55 +0300 Subject: [PATCH 3/8] Added disabling color --- apps/public-web/src/EShopOnAbp.PublicWeb/Pages/index.css | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/apps/public-web/src/EShopOnAbp.PublicWeb/Pages/index.css b/apps/public-web/src/EShopOnAbp.PublicWeb/Pages/index.css index fea3c70f..9b2c3929 100644 --- a/apps/public-web/src/EShopOnAbp.PublicWeb/Pages/index.css +++ b/apps/public-web/src/EShopOnAbp.PublicWeb/Pages/index.css @@ -2,6 +2,11 @@ background-color: #f9f9f9; } +a, a:hover, a:visited, a:active { + color: inherit; + text-decoration: none; +} + .product-list-item { background-color: #fff; padding: 2em; From 875ac461286ec25eaf02db96621c2b810e15aeb8 Mon Sep 17 00:00:00 2001 From: malik masis Date: Thu, 28 Jul 2022 14:05:03 +0300 Subject: [PATCH 4/8] Made active the return product page --- .../Components/UserOrders/Default.cshtml | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/apps/public-web/src/EShopOnAbp.PublicWeb/Components/UserOrders/Default.cshtml b/apps/public-web/src/EShopOnAbp.PublicWeb/Components/UserOrders/Default.cshtml index ecb4e0f5..8fa79ae1 100644 --- a/apps/public-web/src/EShopOnAbp.PublicWeb/Components/UserOrders/Default.cshtml +++ b/apps/public-web/src/EShopOnAbp.PublicWeb/Components/UserOrders/Default.cshtml @@ -6,13 +6,16 @@ @model EShopOnAbp.PublicWeb.Components.UserOrders.UserOrderWidgetViewComponent.UserOrderViewModel @inject IStringLocalizer L @inject IOptions options + @if (Model.ServiceError) {
SERVICE ERROR
} + @L["UserOrders:TotalOrderCount"] @Model.UserOrders.Count + @foreach (var order in Model.UserOrders) { var orderTotalString = order.Items.Sum(q => q.UnitPrice * q.Units).ToString("C", new CultureInfo("en-US")); @@ -56,7 +59,7 @@ } - +
@item.ProductName
@L["UserOrders:ProductReturnDate"] @order.OrderDate.AddMonths(1).ToString("dd MMMM yyyy")
@@ -65,10 +68,16 @@ - @L["UserOrders:ReturnProducts"] + + + @L["UserOrders:ReturnProducts"] + + - @L["UserOrders:AddReview"] + + @L["UserOrders:AddReview"] + From c9c6c28bb886d90c1433553585d8b36a15439630 Mon Sep 17 00:00:00 2001 From: malik masis Date: Thu, 28 Jul 2022 14:05:51 +0300 Subject: [PATCH 5/8] Removed the unnecessary click view --- .../Pages/ProductDetail.cshtml | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/apps/public-web/src/EShopOnAbp.PublicWeb/Pages/ProductDetail.cshtml b/apps/public-web/src/EShopOnAbp.PublicWeb/Pages/ProductDetail.cshtml index 5656dc03..b4b9a644 100644 --- a/apps/public-web/src/EShopOnAbp.PublicWeb/Pages/ProductDetail.cshtml +++ b/apps/public-web/src/EShopOnAbp.PublicWeb/Pages/ProductDetail.cshtml @@ -8,10 +8,6 @@ @inject IStringLocalizer L @inject IOptions options -@{ - string pageHeader = Model.Product.Name; -} - @section styles{ } @@ -21,22 +17,16 @@ } -@if (Model.HasRemoteServiceError) -{ - pageHeader = L["CatalogServiceNotAvailable"]; -} -
-

@pageHeader

@{ var product = Model.Product; var productPrice = product.Price.ToString("C", new CultureInfo("en-US")); string productImage = !product.ImageName.IsNullOrEmpty() ? $"{options.Value.RemoteServices.Default.BaseUrl}product-images/{product.ImageName}" : $"{options.Value.RemoteServices.Default.BaseUrl}product-images/@product.ImageName"; string buyText = L["Index:AddToBasket"]; -
+
@product.Name
@@ -58,7 +48,7 @@
- } + }
From 4ccb4e31f1562efb0553ec2f64aa3540eb42a276 Mon Sep 17 00:00:00 2001 From: malik masis Date: Thu, 28 Jul 2022 14:06:29 +0300 Subject: [PATCH 6/8] removed the manual exception handling --- .../Pages/ProductDetail.cshtml.cs | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/apps/public-web/src/EShopOnAbp.PublicWeb/Pages/ProductDetail.cshtml.cs b/apps/public-web/src/EShopOnAbp.PublicWeb/Pages/ProductDetail.cshtml.cs index 220cfeff..99ad7431 100644 --- a/apps/public-web/src/EShopOnAbp.PublicWeb/Pages/ProductDetail.cshtml.cs +++ b/apps/public-web/src/EShopOnAbp.PublicWeb/Pages/ProductDetail.cshtml.cs @@ -12,9 +12,8 @@ namespace EShopOnAbp.PublicWeb.Pages public int OrderNo { get; set; } public ProductDto Product { get; private set; } - public bool HasRemoteServiceError { get; set; } = false; - private readonly IPublicProductAppService _productAppService; + private readonly IPublicProductAppService _productAppService; public ProductDetailModel(IPublicProductAppService productAppService) { @@ -23,16 +22,7 @@ namespace EShopOnAbp.PublicWeb.Pages public async Task OnGet(Guid id) { - try - { - Product = await _productAppService.GetAsync(id); - } - catch (Exception e) - { - Product = new ProductDto(); - HasRemoteServiceError = true; - Console.WriteLine(e); - } + Product = await _productAppService.GetAsync(id); } } } \ No newline at end of file From 757c9cad84ac0a4e5f15ed21ef703cc99b22ab65 Mon Sep 17 00:00:00 2001 From: malik masis Date: Thu, 28 Jul 2022 17:30:23 +0300 Subject: [PATCH 7/8] Added returning detail page once clicking product --- .../Components/UserOrders/Default.cshtml | 24 ++++++++++--------- .../user-orders/user-order-widget.css | 4 ++++ 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/apps/public-web/src/EShopOnAbp.PublicWeb/Components/UserOrders/Default.cshtml b/apps/public-web/src/EShopOnAbp.PublicWeb/Components/UserOrders/Default.cshtml index 8fa79ae1..9bce364f 100644 --- a/apps/public-web/src/EShopOnAbp.PublicWeb/Components/UserOrders/Default.cshtml +++ b/apps/public-web/src/EShopOnAbp.PublicWeb/Components/UserOrders/Default.cshtml @@ -54,25 +54,27 @@
- @{ - string imageUrl = $"{options.Value.RemoteServices.Default.BaseUrl}product-images/{item.PictureUrl}"; - - } + + @{ + string imageUrl = $"{options.Value.RemoteServices.Default.BaseUrl}product-images/{item.PictureUrl}"; + + } + -
@item.ProductName
-
@L["UserOrders:ProductReturnDate"] @order.OrderDate.AddMonths(1).ToString("dd MMMM yyyy")
+ +
@item.ProductName
+
@L["UserOrders:ProductReturnDate"] @order.OrderDate.AddMonths(1).ToString("dd MMMM yyyy")
+
- - - @L["UserOrders:ReturnProducts"] - - + + @L["UserOrders:ReturnProducts"] + diff --git a/apps/public-web/src/EShopOnAbp.PublicWeb/wwwroot/components/user-orders/user-order-widget.css b/apps/public-web/src/EShopOnAbp.PublicWeb/wwwroot/components/user-orders/user-order-widget.css index e69de29b..bfa23e93 100644 --- a/apps/public-web/src/EShopOnAbp.PublicWeb/wwwroot/components/user-orders/user-order-widget.css +++ b/apps/public-web/src/EShopOnAbp.PublicWeb/wwwroot/components/user-orders/user-order-widget.css @@ -0,0 +1,4 @@ +a, a:hover, a:visited, a:active { + color: inherit; + text-decoration: none; +} From 6f9964d957734f5aa49f29df500275d2791cba6e Mon Sep 17 00:00:00 2001 From: malik masis Date: Thu, 28 Jul 2022 18:26:43 +0300 Subject: [PATCH 8/8] changed url ProductDetail/{id} ->products/{id} --- .../EShopOnAbp.PublicWeb/Components/UserOrders/Default.cshtml | 4 ++-- apps/public-web/src/EShopOnAbp.PublicWeb/Pages/Index.cshtml | 2 +- .../src/EShopOnAbp.PublicWeb/Pages/ProductDetail.cshtml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/public-web/src/EShopOnAbp.PublicWeb/Components/UserOrders/Default.cshtml b/apps/public-web/src/EShopOnAbp.PublicWeb/Components/UserOrders/Default.cshtml index 9bce364f..e426ef10 100644 --- a/apps/public-web/src/EShopOnAbp.PublicWeb/Components/UserOrders/Default.cshtml +++ b/apps/public-web/src/EShopOnAbp.PublicWeb/Components/UserOrders/Default.cshtml @@ -54,7 +54,7 @@
- + @{ string imageUrl = $"{options.Value.RemoteServices.Default.BaseUrl}product-images/{item.PictureUrl}"; @@ -62,7 +62,7 @@ - +
@item.ProductName
@L["UserOrders:ProductReturnDate"] @order.OrderDate.AddMonths(1).ToString("dd MMMM yyyy")
diff --git a/apps/public-web/src/EShopOnAbp.PublicWeb/Pages/Index.cshtml b/apps/public-web/src/EShopOnAbp.PublicWeb/Pages/Index.cshtml index 4e0b6485..24b58a5d 100644 --- a/apps/public-web/src/EShopOnAbp.PublicWeb/Pages/Index.cshtml +++ b/apps/public-web/src/EShopOnAbp.PublicWeb/Pages/Index.cshtml @@ -44,7 +44,7 @@ string productImage = !product.ImageName.IsNullOrEmpty() ? $"{options.Value.RemoteServices.Default.BaseUrl}product-images/{product.ImageName}" : $"{options.Value.RemoteServices.Default.BaseUrl}product-images/@product.ImageName"; string buyText = L["Index:AddToBasket"];