6 changed files with 116 additions and 4 deletions
@ -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; } |
|||
} |
|||
@ -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> |
|||
@ -0,0 +1,8 @@ |
|||
using Volo.Abp.Application.Services; |
|||
|
|||
namespace EShopOnAbp.BasketService; |
|||
|
|||
public interface IBasketAppService : IApplicationService |
|||
{ |
|||
|
|||
} |
|||
Loading…
Reference in new issue