diff --git a/apps/public-web/src/EShopOnAbp.PublicWeb/Components/Basket/BasketWidgetViewComponent.cs b/apps/public-web/src/EShopOnAbp.PublicWeb/Components/Basket/BasketWidgetViewComponent.cs index 1f7090ef..dcde32ae 100644 --- a/apps/public-web/src/EShopOnAbp.PublicWeb/Components/Basket/BasketWidgetViewComponent.cs +++ b/apps/public-web/src/EShopOnAbp.PublicWeb/Components/Basket/BasketWidgetViewComponent.cs @@ -1,15 +1,48 @@ -using System.Threading.Tasks; +using System.Collections; +using System.Collections.Generic; +using System.Threading.Tasks; using Microsoft.AspNetCore.Mvc; using Volo.Abp.AspNetCore.Mvc; using Volo.Abp.AspNetCore.Mvc.UI.Widgets; +using EShopOnAbp.BasketService; namespace EShopOnAbp.PublicWeb.Components.Basket; [Widget] public class BasketWidgetViewComponent : AbpViewComponent { + private readonly IBasketAppService _basketAppService; + + public BasketWidgetViewComponent() + { + //_basketAppService = basketAppService; + } + public async Task InvokeAsync() { - return View("~/Components/Basket/Default.cshtml"); + var basketModel = new BasketViewModel(); + basketModel.Items.Add(new BasketItemViewModel{ImageName = "asus.jpg", ProductName = "test-one", Count = 1, TotalPrice = 19}); + basketModel.Items.Add(new BasketItemViewModel{ImageName = "lego.jpg", ProductName = "test-two", Count = 2, TotalPrice = 4}); + basketModel.TotalPrice = 123; + return View("~/Components/Basket/Default.cshtml", basketModel); + } +} + +public class BasketViewModel +{ + public float TotalPrice { get; set; } + public List Items { get; set; } + + public BasketViewModel() + { + Items = new List(); } +} + +public class BasketItemViewModel +{ + public string ProductName { get; set; } + public int Count { get; set; } + public float TotalPrice { get; set; } + public string ImageName { get; set; } } \ No newline at end of file diff --git a/apps/public-web/src/EShopOnAbp.PublicWeb/Components/Basket/Default.cshtml b/apps/public-web/src/EShopOnAbp.PublicWeb/Components/Basket/Default.cshtml index 1845fd64..d7119752 100644 --- a/apps/public-web/src/EShopOnAbp.PublicWeb/Components/Basket/Default.cshtml +++ b/apps/public-web/src/EShopOnAbp.PublicWeb/Components/Basket/Default.cshtml @@ -1,3 +1,38 @@ +@model EShopOnAbp.PublicWeb.Components.Basket.BasketViewModel
-

Basket content will come here!

+ @if (!Model.Items.Any()) + { +

Your basket is empty. You can add products!

+ } + else + { +
+ @foreach (var item in Model.Items) + { +
+ @if (!item.ImageName.IsNullOrEmpty()) + { + + } + else + { + + } + @item.ProductName + @if (item.Count > 1) + { + (@("x" + item.Count)) + } + - $@item.TotalPrice +
+ } +
+
+ Total: $@Model.TotalPrice +
+
+ +
+
+ }
\ No newline at end of file diff --git a/apps/public-web/src/EShopOnAbp.PublicWeb/EShopOnAbp.PublicWeb.csproj b/apps/public-web/src/EShopOnAbp.PublicWeb/EShopOnAbp.PublicWeb.csproj index 27902c50..473fbeb8 100644 --- a/apps/public-web/src/EShopOnAbp.PublicWeb/EShopOnAbp.PublicWeb.csproj +++ b/apps/public-web/src/EShopOnAbp.PublicWeb/EShopOnAbp.PublicWeb.csproj @@ -23,6 +23,7 @@ + diff --git a/apps/public-web/src/EShopOnAbp.PublicWeb/EShopOnAbpPublicWebModule.cs b/apps/public-web/src/EShopOnAbp.PublicWeb/EShopOnAbpPublicWebModule.cs index 23d39a5c..8b4973a6 100644 --- a/apps/public-web/src/EShopOnAbp.PublicWeb/EShopOnAbpPublicWebModule.cs +++ b/apps/public-web/src/EShopOnAbp.PublicWeb/EShopOnAbpPublicWebModule.cs @@ -1,4 +1,5 @@ using System; +using EShopOnAbp.BasketService; using EShopOnAbp.CatalogService; using EShopOnAbp.Localization; using EShopOnAbp.PublicWeb.Menus; @@ -39,7 +40,8 @@ namespace EShopOnAbp.PublicWeb typeof(AbpAccountHttpApiClientModule), typeof(EShopOnAbpSharedHostingAspNetCoreModule), typeof(EShopOnAbpSharedLocalizationModule), - typeof(CatalogServiceHttpApiClientModule) + typeof(CatalogServiceHttpApiClientModule), + typeof(BasketServiceHttpApiClientModule) )] public class EShopOnAbpPublicWebModule : AbpModule { diff --git a/apps/public-web/src/EShopOnAbp.PublicWeb/Pages/Catalog.css b/apps/public-web/src/EShopOnAbp.PublicWeb/Pages/Catalog.css index 4ce2df2f..411340f5 100644 --- a/apps/public-web/src/EShopOnAbp.PublicWeb/Pages/Catalog.css +++ b/apps/public-web/src/EShopOnAbp.PublicWeb/Pages/Catalog.css @@ -28,3 +28,36 @@ .product-info-box { min-height: 80px; } + +.basket-list +{ + background-color: #fff; + padding: 1em; + border: 1px solid #666; + border-radius: 3px; + box-shadow: 0 0 10px rgba(0, 0, 0, .05); + margin-bottom: 0.5em; + transition: all .2s; +} + +.basket-list:hover { + box-shadow: 0 0 20px rgba(0, 0, 0, .1); + cursor: pointer; +} + +.basket-list-item { + margin-top: 1em; +} + +.basket-list-item:first-child{ + margin-top: 0; +} + +.basket-list-item img { + width: 20px; +} + +.basket-total-area +{ + margin-bottom: 1em; +} \ No newline at end of file diff --git a/services/basket/src/EShopOnAbp.BasketService.Application.Contracts/IBasketAppService.cs b/services/basket/src/EShopOnAbp.BasketService.Application.Contracts/IBasketAppService.cs new file mode 100644 index 00000000..b695730d --- /dev/null +++ b/services/basket/src/EShopOnAbp.BasketService.Application.Contracts/IBasketAppService.cs @@ -0,0 +1,8 @@ +using Volo.Abp.Application.Services; + +namespace EShopOnAbp.BasketService; + +public interface IBasketAppService : IApplicationService +{ + +} \ No newline at end of file