9 changed files with 173 additions and 135 deletions
@ -0,0 +1,76 @@ |
|||
@using System.Globalization |
|||
@using EShopOnAbp.Localization |
|||
@using Microsoft.Extensions.Localization |
|||
@model EShopOnAbp.PublicWeb.Components.UserOrders.UserOrderWidgetViewComponent.UserOrderViewModel |
|||
@inject IStringLocalizer<EShopOnAbpResource> L |
|||
|
|||
@if (Model.ServiceError) |
|||
{ |
|||
<div>SERVICE ERROR</div> |
|||
} |
|||
<abp-row class="m-2 p-2" style="text-align: center"> |
|||
<span class="order-title"><strong>@Model.UserOrders.Count sipariş</strong> verildi.</span> |
|||
</abp-row> |
|||
@foreach (var order in Model.UserOrders) |
|||
{ |
|||
var orderTotalString = order.Items.Sum(q => q.UnitPrice).ToString("C", new CultureInfo("en-US")); |
|||
string addressString = $"{order.Address.Street} {order.Address.ZipCode} \n {order.Address.City}/{order.Address.Country}"; |
|||
<div class="card"> |
|||
<div class="card-header"> |
|||
<div class="row"> |
|||
<div class="col"> |
|||
<div class="o-header">Sipariş Tarihi</div> |
|||
<div class="o-description">@order.OrderDate.ToString("dd MMMM yyyy")</div> |
|||
</div> |
|||
<div class="col"> |
|||
<div class="o-header">Toplam</div> |
|||
<div class="o-description">@orderTotalString</div> |
|||
</div> |
|||
<div class="col"> |
|||
<div class="o-header">Teslimat Adresi</div> |
|||
<div> |
|||
<abp-button abp-tooltip-bottom="@addressString">@order.Address.Description</abp-button> |
|||
</div> |
|||
</div> |
|||
<div class="col"> |
|||
<div> |
|||
<span class="o-header">Sipariş No</span> <span class="o-order-no">@order.OrderNo.ToString("N0", new NumberFormatInfo() {NumberGroupSeparator = " "})</span> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
<div class="card-body"> |
|||
@foreach (var item in order.Items) |
|||
{ |
|||
<abp-card class="order-item m-3"> |
|||
<abp-card-body> |
|||
<div class="row m-3"> |
|||
<h3>@order.OrderStatus</h3> |
|||
</div> |
|||
<abp-row> |
|||
<abp-column size="_2"> |
|||
<img class="img-size" src="/product-images/@item.PictureUrl"/> |
|||
</abp-column> |
|||
<abp-column size-lg="_4"> |
|||
<div>@item.ProductName</div> |
|||
<div>Ürünü iade edebileceğiniz son tarih: @order.OrderDate.AddMonths(1).ToString("dd MMMM yyyy")</div> |
|||
<div class="mt-3"> |
|||
<abp-button icon="fas fa-cart-plus" class="btn btn-warning buy-again" text="Tekrar Satın Alın" data-product-id="@item.ProductId"></abp-button> |
|||
</div> |
|||
</abp-column> |
|||
<abp-column offset="_3" size="_2"> |
|||
<abp-row class="pb-3"> |
|||
<abp-button class="btn btn-light shadow" disabled="true" abp-tooltip-right="Not available yet">Ürünleri iade et</abp-button> |
|||
</abp-row> |
|||
<abp-row> |
|||
<abp-button class="btn btn-light shadow" disabled="true" abp-tooltip-right="Not available yet">Ürün yorumu yazın</abp-button> |
|||
</abp-row> |
|||
</abp-column> |
|||
</abp-row> |
|||
</abp-card-body> |
|||
</abp-card> |
|||
} |
|||
</div> |
|||
</div> |
|||
<hr/> |
|||
} |
|||
@ -0,0 +1,12 @@ |
|||
using System.Collections.Generic; |
|||
using Volo.Abp.AspNetCore.Mvc.UI.Bundling; |
|||
|
|||
namespace EShopOnAbp.PublicWeb.Components.UserOrders; |
|||
|
|||
public class UserOrderWidgetScriptContributor : BundleContributor |
|||
{ |
|||
public override void ConfigureBundle(BundleConfigurationContext context) |
|||
{ |
|||
context.Files.AddIfNotContains("/components/user-orders/user-order-widget.js"); |
|||
} |
|||
} |
|||
@ -0,0 +1,12 @@ |
|||
using System.Collections.Generic; |
|||
using Volo.Abp.AspNetCore.Mvc.UI.Bundling; |
|||
|
|||
namespace EShopOnAbp.PublicWeb.Components.UserOrders; |
|||
|
|||
public class UserOrderWidgetStyleContributor : BundleContributor |
|||
{ |
|||
public override void ConfigureBundle(BundleConfigurationContext context) |
|||
{ |
|||
context.Files.AddIfNotContains("/components/user-orders/user-order-widget.css"); |
|||
} |
|||
} |
|||
@ -0,0 +1,48 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Threading.Tasks; |
|||
using EShopOnAbp.OrderingService.Orders; |
|||
using Microsoft.AspNetCore.Mvc; |
|||
using Volo.Abp.AspNetCore.Mvc; |
|||
using Volo.Abp.AspNetCore.Mvc.UI.Widgets; |
|||
|
|||
namespace EShopOnAbp.PublicWeb.Components.UserOrders; |
|||
|
|||
[Widget( |
|||
AutoInitialize = true, |
|||
RefreshUrl = "/Widgets/MyOrders", |
|||
StyleTypes = new[] {typeof(UserOrderWidgetStyleContributor)}, |
|||
ScriptTypes = new[] {typeof(UserOrderWidgetScriptContributor)} |
|||
)] |
|||
public class UserOrderWidgetViewComponent : AbpViewComponent |
|||
{ |
|||
private readonly IOrderAppService _orderAppService; |
|||
public UserOrderViewModel ViewModel { get; set; } = new(); |
|||
|
|||
public UserOrderWidgetViewComponent(IOrderAppService orderAppService) |
|||
{ |
|||
_orderAppService = orderAppService; |
|||
} |
|||
|
|||
public async Task<IViewComponentResult> InvokeAsync(string filter) |
|||
{ |
|||
try |
|||
{ |
|||
ViewModel.UserOrders = await _orderAppService.GetMyOrdersAsync(new GetMyOrdersInput {Filter = filter}); |
|||
} |
|||
catch (Exception e) |
|||
{ |
|||
ViewModel.ServiceError = true; |
|||
ViewModel.UserOrders = new List<OrderDto>(); |
|||
Console.WriteLine(e); |
|||
} |
|||
|
|||
return View("~/Components/UserOrders/Default.cshtml", ViewModel); |
|||
} |
|||
|
|||
public class UserOrderViewModel |
|||
{ |
|||
public List<OrderDto> UserOrders { get; set; } |
|||
public bool ServiceError { get; set; } |
|||
} |
|||
} |
|||
@ -1,22 +1,14 @@ |
|||
using System.Collections.Generic; |
|||
using System.Threading.Tasks; |
|||
using EShopOnAbp.OrderingService.Orders; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.AspNetCore.Mvc.UI.RazorPages; |
|||
|
|||
namespace EShopOnAbp.PublicWeb.Pages; |
|||
|
|||
public class MyOrdersModel : AbpPageModel |
|||
{ |
|||
private readonly IOrderAppService _orderAppService; |
|||
public List<OrderDto> MyOrders { get; set; } |
|||
public string OrderFilter { get; set; } |
|||
|
|||
public MyOrdersModel(IOrderAppService orderAppService) |
|||
public async Task OnGet(string filter) |
|||
{ |
|||
_orderAppService = orderAppService; |
|||
} |
|||
|
|||
public async Task OnGet() |
|||
{ |
|||
MyOrders = await _orderAppService.GetMyOrdersAsync(new GetMyOrdersInput()); |
|||
OrderFilter = filter; |
|||
} |
|||
} |
|||
Loading…
Reference in new issue