Browse Source

Added basket area

pull/37/head
Halil İbrahim Kalkan 5 years ago
parent
commit
d562ef3aef
  1. 37
      apps/public-web/src/EShopOnAbp.PublicWeb/Components/Basket/BasketWidgetViewComponent.cs
  2. 37
      apps/public-web/src/EShopOnAbp.PublicWeb/Components/Basket/Default.cshtml
  3. 1
      apps/public-web/src/EShopOnAbp.PublicWeb/EShopOnAbp.PublicWeb.csproj
  4. 4
      apps/public-web/src/EShopOnAbp.PublicWeb/EShopOnAbpPublicWebModule.cs
  5. 33
      apps/public-web/src/EShopOnAbp.PublicWeb/Pages/Catalog.css
  6. 8
      services/basket/src/EShopOnAbp.BasketService.Application.Contracts/IBasketAppService.cs

37
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<IViewComponentResult> 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<BasketItemViewModel> Items { get; set; }
public BasketViewModel()
{
Items = new List<BasketItemViewModel>();
}
}
public class BasketItemViewModel
{
public string ProductName { get; set; }
public int Count { get; set; }
public float TotalPrice { get; set; }
public string ImageName { get; set; }
}

37
apps/public-web/src/EShopOnAbp.PublicWeb/Components/Basket/Default.cshtml

@ -1,3 +1,38 @@
@model EShopOnAbp.PublicWeb.Components.Basket.BasketViewModel
<div>
<p>Basket content will come here!</p>
@if (!Model.Items.Any())
{
<p>Your basket is empty. You can add products!</p>
}
else
{
<div class="basket-list">
@foreach (var item in Model.Items)
{
<div class="basket-list-item">
@if (!item.ImageName.IsNullOrEmpty())
{
<img src="/product-images/@item.ImageName"/>
}
else
{
<img src="/product-images/noimage.jpg"/>
}
@item.ProductName
@if (item.Count > 1)
{
<text> (@("x" + item.Count))</text>
}
- $@item.TotalPrice
</div>
}
<hr/>
<div class="basket-total-area">
Total: $@Model.TotalPrice
</div>
<div>
<abp-button class="basket-purchase-button" text="Purchase" button-type="Primary" />
</div>
</div>
}
</div>

1
apps/public-web/src/EShopOnAbp.PublicWeb/EShopOnAbp.PublicWeb.csproj

@ -23,6 +23,7 @@
<ProjectReference Include="..\..\..\..\shared\EShopOnAbp.Shared.Hosting.AspNetCore\EShopOnAbp.Shared.Hosting.AspNetCore.csproj" />
<ProjectReference Include="..\..\..\..\shared\EShopOnAbp.Shared.Localization\EShopOnAbp.Shared.Localization.csproj" />
<ProjectReference Include="..\..\..\..\services\catalog\src\EShopOnAbp.CatalogService.HttpApi.Client\EShopOnAbp.CatalogService.HttpApi.Client.csproj" />
<ProjectReference Include="..\..\..\..\services\basket\src\EShopOnAbp.BasketService.HttpApi.Client\EShopOnAbp.BasketService.HttpApi.Client.csproj" />
<!-- <ProjectReference Include="..\..\..\..\services\product\src\MyCompanyName.MyProjectName.ProductService.HttpApi.Client\MyCompanyName.MyProjectName.ProductService.HttpApi.Client.csproj" />-->
</ItemGroup>

4
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
{

33
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;
}

8
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
{
}
Loading…
Cancel
Save