Browse Source

Add new filters to payment request page

pull/69/head
Engincan VESKE 5 years ago
parent
commit
c843c3aeae
  1. 10
      modules/payment/src/Payment.Admin.Application.Contracts/Payments/PaymentRequestGetListInput.cs
  2. 12
      modules/payment/src/Payment.Admin.Application/Payments/PaymentRequestAdminAppService.cs
  3. 92
      modules/payment/src/Payment.Admin.Blazor/Pages/Payment/Requests/Index.razor
  4. 111
      modules/payment/src/Payment.Admin.Blazor/Pages/Payment/Requests/Index.razor.cs
  5. 6
      modules/payment/src/Payment.Admin.HttpApi.Client/ClientProxies/paymentAdmin-generate-proxy.json
  6. 12
      modules/payment/src/Payment.Domain/PaymentRequests/IPaymentRequestRepository.cs
  7. 30
      modules/payment/src/Payment.EntityFrameworkCore/EntityFrameworkCore/Repositories/PaymentRequestRepository.cs

10
modules/payment/src/Payment.Admin.Application.Contracts/Payments/PaymentRequestGetListInput.cs

@ -6,15 +6,11 @@ namespace Payment.Admin.Payments
{ {
public class PaymentRequestGetListInput : PagedAndSortedResultRequestDto public class PaymentRequestGetListInput : PagedAndSortedResultRequestDto
{ {
// public string CustomerId { get; set; } public string ProductName { get; set; }
// public string ProductName { get; set; } public DateTime? MaxCreationTime { get; set; }
public string Filter { get; set; } public DateTime? MinCreationTime { get; set; }
public DateTime? CreationDateMax { get; set; }
public DateTime? CreationDateMin { get; set; }
public PaymentRequestState? Status { get; set; } public PaymentRequestState? Status { get; set; }
} }

12
modules/payment/src/Payment.Admin.Application/Payments/PaymentRequestAdminAppService.cs

@ -21,16 +21,16 @@ namespace Payment.Admin.Payments
input.SkipCount, input.SkipCount,
input.MaxResultCount, input.MaxResultCount,
input.Sorting, input.Sorting,
input.Filter, input.ProductName,
input.CreationDateMax, input.MaxCreationTime,
input.CreationDateMin, input.MinCreationTime,
input.Status input.Status
); );
var totalCount = await PaymentRequestRepository.GetCountAsync( var totalCount = await PaymentRequestRepository.GetCountAsync(
input.Filter, input.ProductName,
input.CreationDateMax, input.MaxCreationTime,
input.CreationDateMin, input.MinCreationTime,
input.Status input.Status
); );

92
modules/payment/src/Payment.Admin.Blazor/Pages/Payment/Requests/Index.razor

@ -1,26 +1,86 @@
@page "/Payment/Requests" @page "/Payment/Requests"
@using global::Payment.Admin.Payments
@using Volo.Abp.AspNetCore.Components.Web.Theming.Layout @using Volo.Abp.AspNetCore.Components.Web.Theming.Layout
@using Blazorise @using global::Payment.Admin.Payments
@using global::Payment.PaymentRequests
@using Volo.Abp.Application.Dtos @using Volo.Abp.Application.Dtos
@using Blazorise
@using Volo.Abp.BlazoriseUI.Components.ObjectExtending @using Volo.Abp.BlazoriseUI.Components.ObjectExtending
@inherits PaymentAdminComponentBase @inherits PaymentAdminComponentBase
@* ************************* PAGE HEADER ************************* *@
<PageHeader Title="@L["PaymentRequests"]" BreadcrumbItems="@BreadcrumbItems" Toolbar="@Toolbar">
</PageHeader>
@* ************************* DATA GRID ************************* *@
<Card> <Card>
<CardHeader>
<h2>@L["PaymentRequests"]</h2>
</CardHeader>
<CardBody> <CardBody>
<AbpExtensibleDataGrid TItem="PaymentRequestWithDetailsDto" <Form>
Data="@Entities" <div id="FilterSection" class="row mt-3">
ReadData="@OnDataGridReadAsync" <Column ColumnSize="ColumnSize.Is3">
TotalItems="@TotalCount" <FieldLabel>@L["ProductName"]</FieldLabel>
ShowPager="true" <TextEdit TValue="string" KeyPress="OnKeyPress" @bind-Text="@GetListInput.ProductName" />
PageSize="@PageSize" </Column>
CurrentPage="@CurrentPage" <Column ColumnSize="ColumnSize.Is3">
Columns="@PaymentRequestTableColumns"> <FieldLabel>@L["Status"]</FieldLabel>
</AbpExtensibleDataGrid> <Select TValue="PaymentRequestState?" @SelectedValue="@GetListInput.Status" SelectedValueChanged="@OnPaymentRequestStateChanged">
@* <SelectItem Value="@((PaymentRequestState?)null)"></SelectItem> *@
@foreach (PaymentRequestState state in Enum.GetValues(typeof(PaymentRequestState)))
{
<SelectItem Value="@((int) state)">@state.ToString()</SelectItem>
}
</Select>
</Column>
<Column ColumnSize="ColumnSize.Is3">
<Field>
<FieldLabel>@L["MinCreationTime"]</FieldLabel>
<DateEdit TValue="DateTime?" Date="@GetListInput.MinCreationTime" DateChanged="OnSelectedDateChangedForMinCreationTime" />
</Field>
</Column>
<Column ColumnSize="ColumnSize.Is3">
<Field>
<FieldLabel>@L["MaxCreationTime"]</FieldLabel>
<DateEdit TValue="DateTime?" Date="@GetListInput.MaxCreationTime" DateChanged="OnSelectedDateChangedForMaxCreationTime" />
</Field>
</Column>
</div>
</Form>
<DataGrid TItem="PaymentRequestWithDetailsDto"
Data="PaymentRequests"
ReadData="OnDataGridReadAsync"
TotalItems="TotalCount"
ShowPager="true"
PageSize="PageSize"
Responsive="true">
<DataGridColumns>
<DataGridColumn TItem="PaymentRequestWithDetailsDto"
Field="ProductName"
Caption="@L["ProductName"]">
</DataGridColumn>
<DataGridColumn TItem="PaymentRequestWithDetailsDto"
Field="CustomerId"
Caption="@L["CustomerId"]">
</DataGridColumn>
<DataGridColumn TItem="PaymentRequestWithDetailsDto"
Field="Currency"
Caption="@L["Currency"]">
</DataGridColumn>
<DataGridColumn TItem="PaymentRequestWithDetailsDto"
Field="Price"
Caption="@L["Price"]">
</DataGridColumn>
<DataGridColumn TItem="PaymentRequestWithDetailsDto"
Field="State"
Caption="@L["State"]">
</DataGridColumn>
<DataGridColumn TItem="PaymentRequestWithDetailsDto"
Field="FailReason"
Caption="@L["FailReason"]">
</DataGridColumn>
<DataGridColumn TItem="PaymentRequestWithDetailsDto"
Field="CreationTime"
Caption="@L["CreationTime"]">
</DataGridColumn>
</DataGridColumns>
</DataGrid>
</CardBody> </CardBody>
</Card> </Card>

111
modules/payment/src/Payment.Admin.Blazor/Pages/Payment/Requests/Index.razor.cs

@ -5,27 +5,21 @@ using System.Threading.Tasks;
using Blazorise; using Blazorise;
using Blazorise.DataGrid; using Blazorise.DataGrid;
using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Web;
using Payment.Admin.Payments; using Payment.Admin.Payments;
using Volo.Abp.Application.Dtos; using Volo.Abp.Application.Dtos;
using Volo.Abp.AspNetCore.Components.Web.Extensibility.TableColumns; using Payment.PaymentRequests;
using Volo.Abp.AspNetCore.Components.Web.Theming.PageToolbars;
using BreadcrumbItem = Volo.Abp.BlazoriseUI.BreadcrumbItem;
namespace Payment.Admin.Pages.Payment.Requests namespace Payment.Admin.Pages.Payment.Requests
{ {
public partial class Index public partial class Index
{ {
[Inject] protected IPaymentRequestAdminAppService PaymentRequestAdminAppService { get; set; } [Inject]
protected IPaymentRequestAdminAppService PaymentRequestAdminAppService { get; set; }
protected PageToolbar Toolbar { get; } = new(); protected IReadOnlyList<PaymentRequestWithDetailsDto> PaymentRequests { get; set; }
protected TableColumnDictionary TableColumns { get; } = new(); protected PaymentRequestGetListInput GetListInput { get; set; }
protected List<TableColumn> PaymentRequestTableColumns => TableColumns.Get<Index>();
protected List<BreadcrumbItem> BreadcrumbItems { get; } = new();
protected IReadOnlyList<PaymentRequestWithDetailsDto> Entities = Array.Empty<PaymentRequestWithDetailsDto>();
protected virtual int PageSize { get; } = LimitedResultRequestDto.DefaultMaxResultCount; protected virtual int PageSize { get; } = LimitedResultRequestDto.DefaultMaxResultCount;
@ -35,63 +29,18 @@ namespace Payment.Admin.Pages.Payment.Requests
protected int? TotalCount { get; set; } protected int? TotalCount { get; set; }
protected PaymentRequestGetListInput GetListInput { get; } = new(); public Index()
protected override async Task OnInitializedAsync()
{
await SetBreadCrumbsAsync();
await SetTableColumnsAsync();
await InvokeAsync(StateHasChanged);
}
private ValueTask SetBreadCrumbsAsync()
{ {
BreadcrumbItems.Add(new BreadcrumbItem(L["Menu:PaymentManagement"])); GetListInput = new();
BreadcrumbItems.Add(new BreadcrumbItem(L["Menu:PaymentRequests"]));
return ValueTask.CompletedTask;
} }
protected virtual ValueTask SetTableColumnsAsync() protected override async Task OnInitializedAsync()
{ {
PaymentRequestTableColumns await GetPaymentRequestsAsync();
.AddRange(new TableColumn[] await InvokeAsync(StateHasChanged);
{
new TableColumn
{
Title = L["DisplayName:CreationTime"],
Data = nameof(PaymentRequestWithDetailsDto.CreationTime)
},
new TableColumn
{
Title = L["DisplayName:Price"],
Data = nameof(PaymentRequestWithDetailsDto.Price)
},
new TableColumn
{
Title = L["DisplayName:Currency"],
Data = nameof(PaymentRequestWithDetailsDto.Currency)
},
new TableColumn
{
Title = L["DisplayName:State"],
Data = nameof(PaymentRequestWithDetailsDto.State)
},
new TableColumn
{
Title = L["DisplayName:ProductName"],
Data = nameof(PaymentRequestWithDetailsDto.ProductName)
},
new TableColumn
{
Title = L["DisplayName:FailReason"],
Data = nameof(PaymentRequestWithDetailsDto.FailReason)
}
});
return ValueTask.CompletedTask;
} }
protected virtual async Task GetEntitiesAsync() protected virtual async Task GetPaymentRequestsAsync()
{ {
try try
{ {
@ -100,8 +49,9 @@ namespace Payment.Admin.Pages.Payment.Requests
GetListInput.MaxResultCount = PageSize; GetListInput.MaxResultCount = PageSize;
var result = await PaymentRequestAdminAppService.GetListAsync(GetListInput); var result = await PaymentRequestAdminAppService.GetListAsync(GetListInput);
Entities = result.Items.As<IReadOnlyList<PaymentRequestWithDetailsDto>>(); PaymentRequests = result.Items.As<IReadOnlyList<PaymentRequestWithDetailsDto>>();
TotalCount = (int?) result.TotalCount; TotalCount = (int?) result.TotalCount;
await InvokeAsync(StateHasChanged);
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -118,8 +68,37 @@ namespace Payment.Admin.Pages.Payment.Requests
CurrentPage = e.Page; CurrentPage = e.Page;
await GetEntitiesAsync(); await GetPaymentRequestsAsync();
await InvokeAsync(StateHasChanged); await InvokeAsync(StateHasChanged);
} }
private async Task OnKeyPress(KeyboardEventArgs e)
{
if (e.Code is "Enter" or "NumpadEnter")
{
await GetPaymentRequestsAsync();
}
}
private async Task OnSelectedDateChangedForMinCreationTime(DateTime? minCreationTime)
{
GetListInput.MinCreationTime = minCreationTime;
await GetPaymentRequestsAsync();
}
private async Task OnSelectedDateChangedForMaxCreationTime(DateTime? maxCreationTime)
{
GetListInput.MaxCreationTime = maxCreationTime;
await GetPaymentRequestsAsync();
}
private async Task OnPaymentRequestStateChanged(PaymentRequestState? status)
{
Console.WriteLine("Status changed!");
Console.WriteLine(status);
GetListInput.Status = status;
await GetPaymentRequestsAsync();
}
} }
} }

6
modules/payment/src/Payment.Admin.HttpApi.Client/ClientProxies/paymentAdmin-generate-proxy.json

@ -33,7 +33,7 @@
"parameters": [ "parameters": [
{ {
"nameOnMethod": "input", "nameOnMethod": "input",
"name": "Filter", "name": "ProductName",
"jsonName": null, "jsonName": null,
"type": "System.String", "type": "System.String",
"typeSimple": "string", "typeSimple": "string",
@ -45,7 +45,7 @@
}, },
{ {
"nameOnMethod": "input", "nameOnMethod": "input",
"name": "CreationDateMax", "name": "MaxCreationTime",
"jsonName": null, "jsonName": null,
"type": "System.DateTime?", "type": "System.DateTime?",
"typeSimple": "string?", "typeSimple": "string?",
@ -57,7 +57,7 @@
}, },
{ {
"nameOnMethod": "input", "nameOnMethod": "input",
"name": "CreationDateMin", "name": "MinCreationTime",
"jsonName": null, "jsonName": null,
"type": "System.DateTime?", "type": "System.DateTime?",
"typeSimple": "string?", "typeSimple": "string?",

12
modules/payment/src/Payment.Domain/PaymentRequests/IPaymentRequestRepository.cs

@ -12,17 +12,17 @@ namespace Payment.PaymentRequests
int skipCount, int skipCount,
int maxResultCount, int maxResultCount,
string sorting, string sorting,
string filter, string productName = null,
DateTime? creationDateMax = null, DateTime? maxCreationTime = null,
DateTime? creationDateMin = null, DateTime? minCreationTime = null,
PaymentRequestState? state = null, PaymentRequestState? state = null,
CancellationToken cancellationToken = default CancellationToken cancellationToken = default
); );
Task<int> GetCountAsync( Task<int> GetCountAsync(
string filter, string productName = null,
DateTime? creationDateMax = null, DateTime? maxCreationTime = null,
DateTime? creationDateMin = null, DateTime? minCreationTime = null,
PaymentRequestState? state = null, PaymentRequestState? state = null,
CancellationToken cancellationToken = default CancellationToken cancellationToken = default
); );

30
modules/payment/src/Payment.EntityFrameworkCore/EntityFrameworkCore/Repositories/PaymentRequestRepository.cs

@ -1,6 +1,7 @@
using System; using System;
using System.Linq; using System.Linq;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq.Dynamic.Core;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
@ -10,7 +11,7 @@ using Volo.Abp.EntityFrameworkCore;
namespace Payment.EntityFrameworkCore.Repositories namespace Payment.EntityFrameworkCore.Repositories
{ {
public class PaymentRequestRepository : EfCoreRepository<IPaymentDbContext, PaymentRequest,Guid>, IPaymentRequestRepository public class PaymentRequestRepository : EfCoreRepository<IPaymentDbContext, PaymentRequest, Guid>, IPaymentRequestRepository
{ {
public PaymentRequestRepository(IDbContextProvider<IPaymentDbContext> dbContextProvider) public PaymentRequestRepository(IDbContextProvider<IPaymentDbContext> dbContextProvider)
: base(dbContextProvider) : base(dbContextProvider)
@ -21,36 +22,35 @@ namespace Payment.EntityFrameworkCore.Repositories
int skipCount, int skipCount,
int maxResultCount, int maxResultCount,
string sorting, string sorting,
string filter, string productName = null,
DateTime? creationDateMax = null, DateTime? maxCreationTime = null,
DateTime? creationDateMin = null, DateTime? minCreationTime = null,
PaymentRequestState? state = null, PaymentRequestState? state = null,
CancellationToken cancellationToken = default CancellationToken cancellationToken = default
) )
{ {
return await (await GetQueryableAsync()) return await (await GetQueryableAsync())
.WhereIf(!string.IsNullOrWhiteSpace(filter), .WhereIf(!string.IsNullOrWhiteSpace(productName), x => x.ProductName.Contains(productName))
x => x.Currency.Contains(filter) || x.ProductName.Contains(filter)) .WhereIf(maxCreationTime != null, p => p.CreationTime <= maxCreationTime)
.WhereIf(creationDateMax != null, p => p.CreationTime <= creationDateMax) .WhereIf(minCreationTime != null, p => p.CreationTime >= minCreationTime)
.WhereIf(creationDateMin != null, p => p.CreationTime >= creationDateMin)
.WhereIf(state != null, p => p.State == state) .WhereIf(state != null, p => p.State == state)
.OrderBy(string.IsNullOrWhiteSpace(sorting) ? nameof(PaymentRequest.ProductName) : sorting)
.PageBy(skipCount, maxResultCount) .PageBy(skipCount, maxResultCount)
.ToListAsync(GetCancellationToken(cancellationToken)); .ToListAsync(GetCancellationToken(cancellationToken));
} }
public async Task<int> GetCountAsync( public async Task<int> GetCountAsync(
string filter, string productName = null,
DateTime? creationDateMax = null, DateTime? maxCreationTime = null,
DateTime? creationDateMin = null, DateTime? minCreationTime = null,
PaymentRequestState? state = null, PaymentRequestState? state = null,
CancellationToken cancellationToken = default CancellationToken cancellationToken = default
) )
{ {
return await (await GetQueryableAsync()) return await (await GetQueryableAsync())
.WhereIf(!string.IsNullOrWhiteSpace(filter), .WhereIf(!string.IsNullOrWhiteSpace(productName), x => x.ProductName.Contains(productName))
x => x.Currency.Contains(filter) || x.ProductName.Contains(filter)) .WhereIf(maxCreationTime != null, p => p.CreationTime <= maxCreationTime)
.WhereIf(creationDateMax != null, p => p.CreationTime <= creationDateMax) .WhereIf(minCreationTime != null, p => p.CreationTime >= minCreationTime)
.WhereIf(creationDateMin != null, p => p.CreationTime >= creationDateMin)
.WhereIf(state != null, p => p.State == state) .WhereIf(state != null, p => p.State == state)
.CountAsync(GetCancellationToken(cancellationToken)); .CountAsync(GetCancellationToken(cancellationToken));
} }

Loading…
Cancel
Save