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 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? CreationDateMax { get; set; }
public DateTime? CreationDateMin { get; set; }
public DateTime? MinCreationTime { 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.MaxResultCount,
input.Sorting,
input.Filter,
input.CreationDateMax,
input.CreationDateMin,
input.ProductName,
input.MaxCreationTime,
input.MinCreationTime,
input.Status
);
var totalCount = await PaymentRequestRepository.GetCountAsync(
input.Filter,
input.CreationDateMax,
input.CreationDateMin,
input.ProductName,
input.MaxCreationTime,
input.MinCreationTime,
input.Status
);

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

@ -1,26 +1,86 @@
@page "/Payment/Requests"
@using global::Payment.Admin.Payments
@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 Blazorise
@using Volo.Abp.BlazoriseUI.Components.ObjectExtending
@inherits PaymentAdminComponentBase
@* ************************* PAGE HEADER ************************* *@
<PageHeader Title="@L["PaymentRequests"]" BreadcrumbItems="@BreadcrumbItems" Toolbar="@Toolbar">
</PageHeader>
@* ************************* DATA GRID ************************* *@
<Card>
<CardHeader>
<h2>@L["PaymentRequests"]</h2>
</CardHeader>
<CardBody>
<AbpExtensibleDataGrid TItem="PaymentRequestWithDetailsDto"
Data="@Entities"
ReadData="@OnDataGridReadAsync"
TotalItems="@TotalCount"
ShowPager="true"
PageSize="@PageSize"
CurrentPage="@CurrentPage"
Columns="@PaymentRequestTableColumns">
</AbpExtensibleDataGrid>
<Form>
<div id="FilterSection" class="row mt-3">
<Column ColumnSize="ColumnSize.Is3">
<FieldLabel>@L["ProductName"]</FieldLabel>
<TextEdit TValue="string" KeyPress="OnKeyPress" @bind-Text="@GetListInput.ProductName" />
</Column>
<Column ColumnSize="ColumnSize.Is3">
<FieldLabel>@L["Status"]</FieldLabel>
<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>
</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.DataGrid;
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Web;
using Payment.Admin.Payments;
using Volo.Abp.Application.Dtos;
using Volo.Abp.AspNetCore.Components.Web.Extensibility.TableColumns;
using Volo.Abp.AspNetCore.Components.Web.Theming.PageToolbars;
using BreadcrumbItem = Volo.Abp.BlazoriseUI.BreadcrumbItem;
using Payment.PaymentRequests;
namespace Payment.Admin.Pages.Payment.Requests
{
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 List<TableColumn> PaymentRequestTableColumns => TableColumns.Get<Index>();
protected List<BreadcrumbItem> BreadcrumbItems { get; } = new();
protected IReadOnlyList<PaymentRequestWithDetailsDto> Entities = Array.Empty<PaymentRequestWithDetailsDto>();
protected PaymentRequestGetListInput GetListInput { get; set; }
protected virtual int PageSize { get; } = LimitedResultRequestDto.DefaultMaxResultCount;
@ -35,63 +29,18 @@ namespace Payment.Admin.Pages.Payment.Requests
protected int? TotalCount { get; set; }
protected PaymentRequestGetListInput GetListInput { get; } = new();
protected override async Task OnInitializedAsync()
{
await SetBreadCrumbsAsync();
await SetTableColumnsAsync();
await InvokeAsync(StateHasChanged);
}
private ValueTask SetBreadCrumbsAsync()
public Index()
{
BreadcrumbItems.Add(new BreadcrumbItem(L["Menu:PaymentManagement"]));
BreadcrumbItems.Add(new BreadcrumbItem(L["Menu:PaymentRequests"]));
return ValueTask.CompletedTask;
GetListInput = new();
}
protected virtual ValueTask SetTableColumnsAsync()
protected override async Task OnInitializedAsync()
{
PaymentRequestTableColumns
.AddRange(new TableColumn[]
{
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;
await GetPaymentRequestsAsync();
await InvokeAsync(StateHasChanged);
}
protected virtual async Task GetEntitiesAsync()
protected virtual async Task GetPaymentRequestsAsync()
{
try
{
@ -100,8 +49,9 @@ namespace Payment.Admin.Pages.Payment.Requests
GetListInput.MaxResultCount = PageSize;
var result = await PaymentRequestAdminAppService.GetListAsync(GetListInput);
Entities = result.Items.As<IReadOnlyList<PaymentRequestWithDetailsDto>>();
PaymentRequests = result.Items.As<IReadOnlyList<PaymentRequestWithDetailsDto>>();
TotalCount = (int?) result.TotalCount;
await InvokeAsync(StateHasChanged);
}
catch (Exception ex)
{
@ -118,8 +68,37 @@ namespace Payment.Admin.Pages.Payment.Requests
CurrentPage = e.Page;
await GetEntitiesAsync();
await GetPaymentRequestsAsync();
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": [
{
"nameOnMethod": "input",
"name": "Filter",
"name": "ProductName",
"jsonName": null,
"type": "System.String",
"typeSimple": "string",
@ -45,7 +45,7 @@
},
{
"nameOnMethod": "input",
"name": "CreationDateMax",
"name": "MaxCreationTime",
"jsonName": null,
"type": "System.DateTime?",
"typeSimple": "string?",
@ -57,7 +57,7 @@
},
{
"nameOnMethod": "input",
"name": "CreationDateMin",
"name": "MinCreationTime",
"jsonName": null,
"type": "System.DateTime?",
"typeSimple": "string?",

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

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

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

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

Loading…
Cancel
Save