Browse Source

Updated UI response for catalog service unavailability

ipaddr
Galip Tolga Erdem 5 years ago
parent
commit
ac84bee546
  1. 15
      apps/public-web/src/EShopOnAbp.PublicWeb/Pages/Index.cshtml
  2. 17
      apps/public-web/src/EShopOnAbp.PublicWeb/Pages/Index.cshtml.cs
  3. 1
      shared/EShopOnAbp.Shared.Localization/Localization/EShopOnAbp/en.json
  4. 1
      shared/EShopOnAbp.Shared.Localization/Localization/EShopOnAbp/tr.json

15
apps/public-web/src/EShopOnAbp.PublicWeb/Pages/Index.cshtml

@ -6,21 +6,28 @@
@{
const int productsColumnSize = 4; // TODO: update abp-column helper to plain html for proper row and columns css
string pageHeader = L["OurProducts"];
}
@section styles{
<abp-style src="/Pages/index.css"/>
}
@section scripts {
<abp-script src="/client-proxies/basket-proxy.js" />
<abp-script src="/Pages/index.js" />
<abp-script src="/client-proxies/basket-proxy.js"/>
<abp-script src="/Pages/index.js"/>
}
@if (Model.HasRemoteServiceError)
{
pageHeader = L["CatalogServiceNotAvailable"];
}
<div class="row">
<div class="col-lg-12">
<h3 class="pt-5 pb-4 text-center">@L["OurProducts"]</h3>
<h3 class="pt-5 pb-4 text-center">@pageHeader</h3>
<div class="product-list">
@for (int i = 0; i < Math.Ceiling(Model.Products.Count / (double)productsColumnSize); i++)
@for (int i = 0; i < Math.Ceiling(Model.Products.Count / (double) productsColumnSize); i++)
{
<abp-row>
@for (int j = 0; j < productsColumnSize; j++)

17
apps/public-web/src/EShopOnAbp.PublicWeb/Pages/Index.cshtml.cs

@ -1,4 +1,6 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Threading.Tasks;
using EShopOnAbp.CatalogService.Products;
using Microsoft.AspNetCore.Authentication;
@ -9,6 +11,7 @@ namespace EShopOnAbp.PublicWeb.Pages
public class IndexModel : AbpPageModel
{
public IReadOnlyList<ProductDto> Products { get; private set; }
public bool HasRemoteServiceError { get; set; } = false;
private readonly IPublicProductAppService _productAppService;
public IndexModel(IPublicProductAppService productAppService)
@ -18,7 +21,17 @@ namespace EShopOnAbp.PublicWeb.Pages
public async Task OnGet()
{
Products = (await _productAppService.GetListAsync()).Items;
try
{
Products = (await _productAppService.GetListAsync()).Items;
}
catch (Exception e)
{
Products = new ReadOnlyCollection<ProductDto>(new List<ProductDto>());
HasRemoteServiceError = true;
Console.WriteLine(e);
}
}
public async Task OnPostLoginAsync()

1
shared/EShopOnAbp.Shared.Localization/Localization/EShopOnAbp/en.json

@ -6,6 +6,7 @@
"YourBasket": "Your Basket",
"Total": "Total",
"OurProducts": "Our Products",
"CatalogServiceNotAvailable": "Catalog Service is unavailable right now! Try again later...",
"StockCount": "Stock Count",
"RemoveFromBasket": "Remove from basket",
"CompletePurchase": "Complete purchase",

1
shared/EShopOnAbp.Shared.Localization/Localization/EShopOnAbp/tr.json

@ -6,6 +6,7 @@
"YourBasket": "Sepetiniz",
"Total": "Toplam",
"OurProducts": "Ürünlerimiz",
"CatalogServiceNotAvailable": "Ürün servisine şu anda ulaşılamıyor! Lütfen sonra tekrar deneyiniz...",
"StockCount": "Stokta",
"RemoveFromBasket": "Sepetten kaldır",
"CompletePurchase": "Alışverişi tamamla",

Loading…
Cancel
Save