From fbca126b5528b9b87ab65917e93adbed25d561f4 Mon Sep 17 00:00:00 2001 From: Mirko Da Corte Date: Mon, 24 Jan 2022 19:24:52 +0100 Subject: [PATCH 1/4] Updated logs pagination --- src/EthernaCredit.Services/EthernaCredit.Services.csproj | 4 ++-- src/EthernaCredit/Areas/Manage/Pages/Logs.cshtml | 2 +- src/EthernaCredit/Areas/Manage/Pages/Logs.cshtml.cs | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/EthernaCredit.Services/EthernaCredit.Services.csproj b/src/EthernaCredit.Services/EthernaCredit.Services.csproj index 0d3a4f9..fcca27c 100644 --- a/src/EthernaCredit.Services/EthernaCredit.Services.csproj +++ b/src/EthernaCredit.Services/EthernaCredit.Services.csproj @@ -1,4 +1,4 @@ - + net5.0 @@ -20,7 +20,7 @@ - + diff --git a/src/EthernaCredit/Areas/Manage/Pages/Logs.cshtml b/src/EthernaCredit/Areas/Manage/Pages/Logs.cshtml index 474c842..fef74f3 100644 --- a/src/EthernaCredit/Areas/Manage/Pages/Logs.cshtml +++ b/src/EthernaCredit/Areas/Manage/Pages/Logs.cshtml @@ -19,7 +19,7 @@ ViewData["Title"] = "Operation logs"; ViewData["ActivePage"] = ManageNavPages.Logs; - var pageSelectorModel = new PageSelectorModel(Model.CurrentPage, Model.MaxPage); + var pageSelectorModel = new PageSelectorModel(Model.CurrentPage, Model.MaxPage, 1); }

@ViewData["Title"]

diff --git a/src/EthernaCredit/Areas/Manage/Pages/Logs.cshtml.cs b/src/EthernaCredit/Areas/Manage/Pages/Logs.cshtml.cs index a16db8c..21ac60d 100644 --- a/src/EthernaCredit/Areas/Manage/Pages/Logs.cshtml.cs +++ b/src/EthernaCredit/Areas/Manage/Pages/Logs.cshtml.cs @@ -48,7 +48,7 @@ public LogsModel( public IEnumerable Logs { get; private set; } = Array.Empty(); // Methods. - public async Task OnGetAsync(int p) + public async Task OnGetAsync(int p = 1) { // Get user. var (user, _) = await userService.FindUserAsync(User.GetEtherAddress()); @@ -57,11 +57,11 @@ public async Task OnGetAsync(int p) var paginatedLogs = await dbContext.OperationLogs.QueryPaginatedElementsAsync( elements => elements.Where(l => l.User.Id == user.Id), l => l.CreationDateTime, - p, DefaultTakeElements, + p - 1, DefaultTakeElements, true); - CurrentPage = paginatedLogs.CurrentPage; - MaxPage = paginatedLogs.MaxPage; + CurrentPage = paginatedLogs.CurrentPage + 1; + MaxPage = paginatedLogs.MaxPage + 1; Logs = paginatedLogs.Elements; } } From ae805b680df1838452ca456851698461ec5721dc Mon Sep 17 00:00:00 2001 From: Mirko Da Corte Date: Mon, 24 Jan 2022 22:45:47 +0100 Subject: [PATCH 2/4] Migrated to EthernaACR --- src/EthernaCredit.Services/EthernaCredit.Services.csproj | 2 +- .../EventHandlers/OnUserDepositThenSendEmailHandler.cs | 3 +-- .../EventHandlers/OnUserWithdrawThenSendEmailHandler.cs | 2 +- src/EthernaCredit.Services/ServiceCollectionExtensions.cs | 2 +- src/EthernaCredit/Areas/Admin/Pages/_ViewImports.cshtml | 4 ++-- src/EthernaCredit/Areas/Manage/Pages/_ViewImports.cshtml | 2 +- src/EthernaCredit/Program.cs | 4 ++-- src/EthernaCredit/Startup.cs | 4 ++-- 8 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/EthernaCredit.Services/EthernaCredit.Services.csproj b/src/EthernaCredit.Services/EthernaCredit.Services.csproj index fcca27c..f363cba 100644 --- a/src/EthernaCredit.Services/EthernaCredit.Services.csproj +++ b/src/EthernaCredit.Services/EthernaCredit.Services.csproj @@ -19,8 +19,8 @@ + - diff --git a/src/EthernaCredit.Services/EventHandlers/OnUserDepositThenSendEmailHandler.cs b/src/EthernaCredit.Services/EventHandlers/OnUserDepositThenSendEmailHandler.cs index 7cf1563..0ac2503 100644 --- a/src/EthernaCredit.Services/EventHandlers/OnUserDepositThenSendEmailHandler.cs +++ b/src/EthernaCredit.Services/EventHandlers/OnUserDepositThenSendEmailHandler.cs @@ -12,13 +12,12 @@ // See the License for the specific language governing permissions and // limitations under the License. +using Etherna.ACR.Services; using Etherna.CreditSystem.Domain; using Etherna.CreditSystem.Domain.Events; -using Etherna.CreditSystem.Services.Domain; using Etherna.CreditSystem.Services.Views.Emails; using Etherna.DomainEvents; using Etherna.ServicesClient.Clients.Sso; -using Etherna.SSL.Services; using System.Threading.Tasks; namespace Etherna.CreditSystem.Services.EventHandlers diff --git a/src/EthernaCredit.Services/EventHandlers/OnUserWithdrawThenSendEmailHandler.cs b/src/EthernaCredit.Services/EventHandlers/OnUserWithdrawThenSendEmailHandler.cs index 35cae6b..72caa2d 100644 --- a/src/EthernaCredit.Services/EventHandlers/OnUserWithdrawThenSendEmailHandler.cs +++ b/src/EthernaCredit.Services/EventHandlers/OnUserWithdrawThenSendEmailHandler.cs @@ -12,12 +12,12 @@ // See the License for the specific language governing permissions and // limitations under the License. +using Etherna.ACR.Services; using Etherna.CreditSystem.Domain; using Etherna.CreditSystem.Domain.Events; using Etherna.CreditSystem.Services.Views.Emails; using Etherna.DomainEvents; using Etherna.ServicesClient.Clients.Sso; -using Etherna.SSL.Services; using System.Threading.Tasks; namespace Etherna.CreditSystem.Services.EventHandlers diff --git a/src/EthernaCredit.Services/ServiceCollectionExtensions.cs b/src/EthernaCredit.Services/ServiceCollectionExtensions.cs index 1f7dc59..b49c217 100644 --- a/src/EthernaCredit.Services/ServiceCollectionExtensions.cs +++ b/src/EthernaCredit.Services/ServiceCollectionExtensions.cs @@ -12,10 +12,10 @@ // See the License for the specific language governing permissions and // limitations under the License. +using Etherna.ACR; using Etherna.CreditSystem.Services.Domain; using Etherna.DomainEvents; using Etherna.DomainEvents.AspNetCore; -using Etherna.SSL; using Microsoft.Extensions.DependencyInjection; using System; using System.Linq; diff --git a/src/EthernaCredit/Areas/Admin/Pages/_ViewImports.cshtml b/src/EthernaCredit/Areas/Admin/Pages/_ViewImports.cshtml index 7be05cb..218440a 100644 --- a/src/EthernaCredit/Areas/Admin/Pages/_ViewImports.cshtml +++ b/src/EthernaCredit/Areas/Admin/Pages/_ViewImports.cshtml @@ -13,10 +13,10 @@ * limitations under the License. *@ +@using Etherna.ACR +@using Etherna.ACR.Pages.SharedModels @using Etherna.CreditSystem.Areas.Admin @using Etherna.CreditSystem.Areas.Admin.Pages @using Etherna.CreditSystem.Configs @using Etherna.CreditSystem.Domain.Models -@using Etherna.SSL -@using Etherna.SSL.Pages.SharedModels @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers \ No newline at end of file diff --git a/src/EthernaCredit/Areas/Manage/Pages/_ViewImports.cshtml b/src/EthernaCredit/Areas/Manage/Pages/_ViewImports.cshtml index 3cc8379..cb1efa8 100644 --- a/src/EthernaCredit/Areas/Manage/Pages/_ViewImports.cshtml +++ b/src/EthernaCredit/Areas/Manage/Pages/_ViewImports.cshtml @@ -13,9 +13,9 @@ * limitations under the License. *@ +@using Etherna.ACR.Pages.SharedModels @using Etherna.CreditSystem.Domain.Models @using Etherna.CreditSystem.Domain.Models.OperationLogs @using Etherna.CreditSystem.Extensions -@using Etherna.SSL.Pages.SharedModels @namespace Etherna.CreditSystem.Areas.Manage.Pages @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers diff --git a/src/EthernaCredit/Program.cs b/src/EthernaCredit/Program.cs index 6703b2c..b3fecb6 100644 --- a/src/EthernaCredit/Program.cs +++ b/src/EthernaCredit/Program.cs @@ -12,8 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -using Etherna.SSL.Exceptions; -using Etherna.SSL.Filters; +using Etherna.ACR.Exceptions; +using Etherna.ACR.Filters; using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; diff --git a/src/EthernaCredit/Startup.cs b/src/EthernaCredit/Startup.cs index d7239c6..bd7179b 100644 --- a/src/EthernaCredit/Startup.cs +++ b/src/EthernaCredit/Startup.cs @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +using Etherna.ACR.Exceptions; +using Etherna.ACR.Settings; using Etherna.CreditSystem.Configs; using Etherna.CreditSystem.Configs.Authorization; using Etherna.CreditSystem.Configs.Hangfire; @@ -26,8 +28,6 @@ using Etherna.MongODM; using Etherna.MongODM.AspNetCore.UI; using Etherna.MongODM.Core.Options; -using Etherna.SSL.Exceptions; -using Etherna.SSL.Settings; using Hangfire; using Hangfire.Mongo; using Hangfire.Mongo.Migration.Strategies; From 744350c59be94acba45eac287d1ca49d4bf1f81b Mon Sep 17 00:00:00 2001 From: Mirko Da Corte Date: Mon, 24 Jan 2022 22:59:27 +0100 Subject: [PATCH 3/4] Migrated from dollars to CHF --- src/EthernaCredit/Areas/Deposit/Pages/DepositProcess.cshtml | 4 ++-- src/EthernaCredit/Areas/Manage/Pages/Deposit.cshtml | 4 ++-- src/EthernaCredit/Areas/Manage/Pages/Index.cshtml | 2 +- src/EthernaCredit/Areas/Manage/Pages/Logs.cshtml | 2 +- src/EthernaCredit/Areas/Manage/Pages/Withdraw.cshtml | 4 ++-- src/EthernaCredit/Areas/Withdraw/Pages/WithdrawProcess.cshtml | 4 ++-- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/EthernaCredit/Areas/Deposit/Pages/DepositProcess.cshtml b/src/EthernaCredit/Areas/Deposit/Pages/DepositProcess.cshtml index da500e5..91112eb 100644 --- a/src/EthernaCredit/Areas/Deposit/Pages/DepositProcess.cshtml +++ b/src/EthernaCredit/Areas/Deposit/Pages/DepositProcess.cshtml @@ -24,11 +24,11 @@
@if (Model.SucceededResult) { -

An amount of @Model.DepositAmount.ToFinancialString(prefixSymbol: "$") has been deposited to your account

+

An amount of @Model.DepositAmount.ToFinancialString(suffixSymbol: " CHF") has been deposited to your account

} else { -

Sorry, we was not able to deposit an amount of @Model.DepositAmount.ToFinancialString(prefixSymbol: "$") to your account

+

Sorry, we was not able to deposit an amount of @Model.DepositAmount.ToFinancialString(suffixSymbol: " CHF") to your account

}

Return to account

diff --git a/src/EthernaCredit/Areas/Manage/Pages/Deposit.cshtml b/src/EthernaCredit/Areas/Manage/Pages/Deposit.cshtml index b0b3e6d..3d6018d 100644 --- a/src/EthernaCredit/Areas/Manage/Pages/Deposit.cshtml +++ b/src/EthernaCredit/Areas/Manage/Pages/Deposit.cshtml @@ -27,12 +27,12 @@

- @foreach (var amount in new[] { 0.1m, 0.5m, 1m, 5m, 10m }) + @foreach (var amount in new[] { 0.5m, 1m, 5m, 10m }) { + value="@amount">@amount.ToFinancialString(suffixSymbol: " CHF") }

diff --git a/src/EthernaCredit/Areas/Manage/Pages/Index.cshtml b/src/EthernaCredit/Areas/Manage/Pages/Index.cshtml index f89c88f..3721744 100644 --- a/src/EthernaCredit/Areas/Manage/Pages/Index.cshtml +++ b/src/EthernaCredit/Areas/Manage/Pages/Index.cshtml @@ -30,7 +30,7 @@
-

@Model.CreditBalance.ToFinancialString(prefixSymbol: "$")

+

@Model.CreditBalance.ToFinancialString(suffixSymbol: " CHF")

@if (Model.HasUnlimitedCredit) { diff --git a/src/EthernaCredit/Areas/Manage/Pages/Logs.cshtml b/src/EthernaCredit/Areas/Manage/Pages/Logs.cshtml index fef74f3..0d3baef 100644 --- a/src/EthernaCredit/Areas/Manage/Pages/Logs.cshtml +++ b/src/EthernaCredit/Areas/Manage/Pages/Logs.cshtml @@ -42,7 +42,7 @@ } @log.Amount.ToFinancialString( allowedDecimals: null, - prefixSymbol: "$", + suffixSymbol: " CHF", usePlusSign: true)

diff --git a/src/EthernaCredit/Areas/Manage/Pages/Withdraw.cshtml b/src/EthernaCredit/Areas/Manage/Pages/Withdraw.cshtml index 9ad897e..6e0560f 100644 --- a/src/EthernaCredit/Areas/Manage/Pages/Withdraw.cshtml +++ b/src/EthernaCredit/Areas/Manage/Pages/Withdraw.cshtml @@ -27,8 +27,8 @@ @if (Model.CanWithdraw) {

How much do you want to withdraw from your account? ( - min: @Model.MinLimit.ToFinancialString(roundMode: MidpointRounding.ToZero, prefixSymbol: "$"), - max: @Model.MaxLimit.ToFinancialString(roundMode: MidpointRounding.ToZero, prefixSymbol: "$"))

+ min: @Model.MinLimit.ToFinancialString(roundMode: MidpointRounding.ToZero, suffixSymbol: " CHF"), + max: @Model.MaxLimit.ToFinancialString(roundMode: MidpointRounding.ToZero, suffixSymbol: " CHF"))

diff --git a/src/EthernaCredit/Areas/Withdraw/Pages/WithdrawProcess.cshtml b/src/EthernaCredit/Areas/Withdraw/Pages/WithdrawProcess.cshtml index ec4de4e..b458f50 100644 --- a/src/EthernaCredit/Areas/Withdraw/Pages/WithdrawProcess.cshtml +++ b/src/EthernaCredit/Areas/Withdraw/Pages/WithdrawProcess.cshtml @@ -24,11 +24,11 @@
@if (Model.SucceededResult) { -

An amount of @Model.WithdrawAmount.ToFinancialString(prefixSymbol: "$") has been withdrawn from your account

+

An amount of @Model.WithdrawAmount.ToFinancialString(suffixSymbol: " CHF") has been withdrawn from your account

} else { -

Sorry, we was not able to withdraw an amount of @Model.WithdrawAmount.ToFinancialString(prefixSymbol: "$") from your account

+

Sorry, we was not able to withdraw an amount of @Model.WithdrawAmount.ToFinancialString(suffixSymbol: " CHF") from your account

}

Return to account

From e090ce240ec6f8cf83d33b2c3f3d7b39644440c4 Mon Sep 17 00:00:00 2001 From: Mirko Da Corte Date: Mon, 24 Jan 2022 23:24:21 +0100 Subject: [PATCH 4/4] Added financial formatting in admin area --- src/EthernaCredit/Areas/Admin/Pages/Users/Index.cshtml | 6 +++++- src/EthernaCredit/Areas/Admin/Pages/_ViewImports.cshtml | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/EthernaCredit/Areas/Admin/Pages/Users/Index.cshtml b/src/EthernaCredit/Areas/Admin/Pages/Users/Index.cshtml index c87b17f..97f8358 100644 --- a/src/EthernaCredit/Areas/Admin/Pages/Users/Index.cshtml +++ b/src/EthernaCredit/Areas/Admin/Pages/Users/Index.cshtml @@ -68,7 +68,11 @@ @user.Id @user.EtherAddress - @user.Balance + + @user.Balance.ToFinancialString( + allowedDecimals: 4, + suffixSymbol: " CHF", + usePlusSign: true) @user.HasUnlimitedCredit } diff --git a/src/EthernaCredit/Areas/Admin/Pages/_ViewImports.cshtml b/src/EthernaCredit/Areas/Admin/Pages/_ViewImports.cshtml index 218440a..31c9c75 100644 --- a/src/EthernaCredit/Areas/Admin/Pages/_ViewImports.cshtml +++ b/src/EthernaCredit/Areas/Admin/Pages/_ViewImports.cshtml @@ -19,4 +19,5 @@ @using Etherna.CreditSystem.Areas.Admin.Pages @using Etherna.CreditSystem.Configs @using Etherna.CreditSystem.Domain.Models +@using Etherna.CreditSystem.Extensions @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers \ No newline at end of file