mirror of
https://github.com/claunia/marechai.git
synced 2025-12-16 11:04:25 +00:00
Add currency inflation admin page.
This commit is contained in:
@@ -31,7 +31,8 @@ namespace Marechai.Database.Models
|
||||
{
|
||||
[Required]
|
||||
public virtual Iso4217 Currency { get; set; }
|
||||
public uint Year { get; set; }
|
||||
public float Inflation { get; set; }
|
||||
public uint Year { get; set; }
|
||||
public float Inflation { get; set; }
|
||||
public string CurrencyCode { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
<Version>4.0.0.1792</Version>
|
||||
<Version>4.0.0.1800</Version>
|
||||
<Company>Canary Islands Computer Museum</Company>
|
||||
<Copyright>Copyright © 2003-2020 Natalia Portillo</Copyright>
|
||||
<Product>Canary Islands Computer Museum Website</Product>
|
||||
|
||||
98
Marechai/Pages/Admin/CurrencyInflation.razor
Normal file
98
Marechai/Pages/Admin/CurrencyInflation.razor
Normal file
@@ -0,0 +1,98 @@
|
||||
@{
|
||||
/******************************************************************************
|
||||
// MARECHAI: Master repository of computing history artifacts information
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// --[ License ] --------------------------------------------------------------
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
// Copyright © 2003-2020 Natalia Portillo
|
||||
*******************************************************************************/
|
||||
}
|
||||
|
||||
@page "/admin/currency_inflation"
|
||||
@using Marechai.Database.Models
|
||||
@inherits OwningComponentBase<CurrencyInflationService>
|
||||
@inject IStringLocalizer<CurrencyInflationService> L
|
||||
@inject Microsoft.AspNetCore.Identity.UserManager<ApplicationUser> UserManager
|
||||
@inject AuthenticationStateProvider AuthenticationStateProvider
|
||||
@attribute [Authorize(Roles = "UberAdmin, Admin")]
|
||||
<h3>@L["Currency inflation"]</h3>
|
||||
@if (_inflations is null)
|
||||
{
|
||||
<p>@L["Loading..."]</p>
|
||||
|
||||
return;
|
||||
}
|
||||
<p>
|
||||
<a class="btn btn-primary" href="/admin/currency_inflation/create">@L["Create new"]</a>
|
||||
</p>
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
@L["Currency"]
|
||||
</th>
|
||||
<th>
|
||||
@L["Year"]
|
||||
</th>
|
||||
<th>
|
||||
@L["Inflation"]
|
||||
</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var item in _inflations)
|
||||
{
|
||||
<tr>
|
||||
<td>
|
||||
@item.CurrencyName
|
||||
</td>
|
||||
<td>
|
||||
@item.Year
|
||||
</td>
|
||||
<td>
|
||||
@($"{item.Inflation:F2}")
|
||||
</td>
|
||||
<td>
|
||||
<a class="btn btn-primary" href="/admin/currency_inflation/details/@item.Id">@L["Details"]</a>
|
||||
<a class="btn btn-secondary" href="/admin/currency_inflation/edit/@item.Id">@L["Edit"]</a>
|
||||
<Button Color="Color.Danger" Clicked="() => {ShowModal(item.Id);}">@L["Delete"]</Button>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<Modal @ref="_frmDelete" IsCentered="true" Closing="@ModalClosing">
|
||||
<ModalBackdrop/>
|
||||
<ModalContent Centered="true">
|
||||
<ModalHeader>
|
||||
<ModalTitle>@L["Delete currency inflation"]</ModalTitle>
|
||||
<CloseButton Clicked="@HideModal"/>
|
||||
</ModalHeader>
|
||||
<ModalBody>
|
||||
<Text>@string.Format(@L["Are you sure you want to delete the inflation of {0:F} happened to currency {1} on {2}?"], _currentInflation?.Inflation, _currentInflation?.CurrencyName, _currentInflation?.Year)</Text>
|
||||
</ModalBody>
|
||||
<ModalFooter>
|
||||
<Button Color="Color.Primary" Clicked="@HideModal" Disabled="@_deleteInProgress">@L["Cancel"]</Button>
|
||||
<Button Color="Color.Danger" Clicked="@ConfirmDelete" Disabled="@_deleteInProgress">@L["Delete"]</Button>
|
||||
</ModalFooter>
|
||||
</ModalContent>
|
||||
</Modal>
|
||||
88
Marechai/Pages/Admin/CurrencyInflation.razor.cs
Normal file
88
Marechai/Pages/Admin/CurrencyInflation.razor.cs
Normal file
@@ -0,0 +1,88 @@
|
||||
/******************************************************************************
|
||||
// MARECHAI: Master repository of computing history artifacts information
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// --[ License ] --------------------------------------------------------------
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
// Copyright © 2003-2020 Natalia Portillo
|
||||
*******************************************************************************/
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Blazorise;
|
||||
using Marechai.ViewModels;
|
||||
using Microsoft.AspNetCore.Components.Authorization;
|
||||
|
||||
namespace Marechai.Pages.Admin
|
||||
{
|
||||
public partial class CurrencyInflation
|
||||
{
|
||||
CurrencyInflationViewModel _currentInflation;
|
||||
bool _deleteInProgress;
|
||||
Modal _frmDelete;
|
||||
List<CurrencyInflationViewModel> _inflations;
|
||||
bool _loaded;
|
||||
|
||||
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||
{
|
||||
if(_loaded)
|
||||
return;
|
||||
|
||||
_inflations = await Service.GetAsync();
|
||||
_loaded = true;
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
void ShowModal(long itemId)
|
||||
{
|
||||
_currentInflation = _inflations.FirstOrDefault(n => n.Id == itemId);
|
||||
_frmDelete.Show();
|
||||
}
|
||||
|
||||
void HideModal() => _frmDelete.Hide();
|
||||
|
||||
async void ConfirmDelete()
|
||||
{
|
||||
if(_currentInflation is null)
|
||||
return;
|
||||
|
||||
_deleteInProgress = true;
|
||||
_inflations = null;
|
||||
AuthenticationState authState = await AuthenticationStateProvider.GetAuthenticationStateAsync();
|
||||
|
||||
// Yield thread to let UI to update
|
||||
await Task.Yield();
|
||||
|
||||
await Service.DeleteAsync(_currentInflation.Id, (await UserManager.GetUserAsync(authState.User)).Id);
|
||||
_inflations = await Service.GetAsync();
|
||||
|
||||
_deleteInProgress = false;
|
||||
_frmDelete.Hide();
|
||||
|
||||
// Yield thread to let UI to update
|
||||
await Task.Yield();
|
||||
|
||||
// Tell we finished loading
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
void ModalClosing(ModalClosingEventArgs obj) => _currentInflation = null;
|
||||
}
|
||||
}
|
||||
94
Marechai/Pages/Admin/Details/CurrencyInflation.razor
Normal file
94
Marechai/Pages/Admin/Details/CurrencyInflation.razor
Normal file
@@ -0,0 +1,94 @@
|
||||
@{
|
||||
/******************************************************************************
|
||||
// MARECHAI: Master repository of computing history artifacts information
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// --[ License ] --------------------------------------------------------------
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
// Copyright © 2003-2020 Natalia Portillo
|
||||
*******************************************************************************/
|
||||
}
|
||||
|
||||
@page "/admin/currency_inflation/details/{Id:int}"
|
||||
@page "/admin/currency_inflation/edit/{Id:int}"
|
||||
@page "/admin/currency_inflation/create"
|
||||
@using Marechai.Database.Models
|
||||
@inherits OwningComponentBase<CurrencyInflationService>
|
||||
@inject IStringLocalizer<CurrencyInflationService> L
|
||||
@inject Iso4217Service CurrenciesService
|
||||
@inject NavigationManager NavigationManager
|
||||
@inject IWebHostEnvironment Host
|
||||
@inject Microsoft.AspNetCore.Identity.UserManager<ApplicationUser> UserManager
|
||||
@inject AuthenticationStateProvider AuthenticationStateProvider
|
||||
@attribute [Authorize(Roles = "UberAdmin, Admin")]
|
||||
|
||||
|
||||
<h3>@L["Currency inflation details"]</h3>
|
||||
<hr />
|
||||
|
||||
@if (!_loaded)
|
||||
{
|
||||
<p align="center">@L["Loading..."]</p>
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
<div>
|
||||
<Field>
|
||||
<FieldLabel>@L["Currency"]</FieldLabel>
|
||||
<Select Disabled="!_editing" TValue="string" @bind-SelectedValue="@_model.CurrencyCode">
|
||||
@foreach (var currency in _currencies)
|
||||
{
|
||||
<SelectItem TValue="string" Value="@currency.Code">@currency.Name</SelectItem>
|
||||
}
|
||||
</Select>
|
||||
</Field>
|
||||
<Field>
|
||||
<FieldLabel>@L["Year"]</FieldLabel>
|
||||
<Validation Validator="@ValidateYear">
|
||||
<NumericEdit Disabled="!_editing" TValue="uint" Decimals="0" @bind-Value="@_model.Year">
|
||||
<Feedback>
|
||||
<ValidationError>@L["Please enter a valid year."]</ValidationError>
|
||||
</Feedback>
|
||||
</NumericEdit>
|
||||
</Validation>
|
||||
</Field>
|
||||
<Field>
|
||||
<FieldLabel>@L["Inflation (ratio)"]</FieldLabel>
|
||||
<Validation Validator="@ValidateInflation">
|
||||
<NumericEdit Disabled="!_editing" TValue="float" Decimals="3" @bind-Value="@_model.Inflation">
|
||||
<Feedback>
|
||||
<ValidationError>@L["Please enter a valid inflation."]</ValidationError>
|
||||
</Feedback>
|
||||
</NumericEdit>
|
||||
</Validation>
|
||||
</Field>
|
||||
</div>
|
||||
<div>
|
||||
@if (!_editing)
|
||||
{
|
||||
<Button Color="Color.Primary" Clicked="@OnEditClicked">@L["Edit"]</Button>
|
||||
}
|
||||
else
|
||||
{
|
||||
<Button Color="Color.Success" Clicked="@OnSaveClicked">@L["Save"]</Button>
|
||||
<Button Color="Color.Danger" Clicked="@OnCancelClicked">@L["Cancel"]</Button>
|
||||
}
|
||||
<a href="/admin/currency_inflation" class="btn btn-secondary">@L["Back to list"]</a>
|
||||
</div>
|
||||
140
Marechai/Pages/Admin/Details/CurrencyInflation.razor.cs
Normal file
140
Marechai/Pages/Admin/Details/CurrencyInflation.razor.cs
Normal file
@@ -0,0 +1,140 @@
|
||||
/******************************************************************************
|
||||
// MARECHAI: Master repository of computing history artifacts information
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// --[ License ] --------------------------------------------------------------
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
// Copyright © 2003-2020 Natalia Portillo
|
||||
*******************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Blazorise;
|
||||
using Marechai.Database.Models;
|
||||
using Marechai.ViewModels;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Microsoft.AspNetCore.Components.Authorization;
|
||||
|
||||
namespace Marechai.Pages.Admin.Details
|
||||
{
|
||||
public partial class CurrencyInflation
|
||||
{
|
||||
AuthenticationState _authState;
|
||||
bool _creating;
|
||||
List<Iso4217> _currencies;
|
||||
bool _editing;
|
||||
bool _loaded;
|
||||
CurrencyInflationViewModel _model;
|
||||
|
||||
[Parameter]
|
||||
public int Id { get; set; }
|
||||
|
||||
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||
{
|
||||
if(_loaded)
|
||||
return;
|
||||
|
||||
_loaded = true;
|
||||
|
||||
_creating = NavigationManager.ToBaseRelativePath(NavigationManager.Uri).ToLowerInvariant().
|
||||
StartsWith("admin/currency_inflation/create",
|
||||
StringComparison.InvariantCulture);
|
||||
|
||||
if(Id <= 0 &&
|
||||
!_creating)
|
||||
return;
|
||||
|
||||
_currencies = await CurrenciesService.GetAsync();
|
||||
_model = _creating ? new CurrencyInflationViewModel() : await Service.GetAsync(Id);
|
||||
_authState = await AuthenticationStateProvider.GetAuthenticationStateAsync();
|
||||
|
||||
_editing = _creating || NavigationManager.ToBaseRelativePath(NavigationManager.Uri).ToLowerInvariant().
|
||||
StartsWith("admin/currency_inflation/edit/",
|
||||
StringComparison.InvariantCulture);
|
||||
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
void OnEditClicked()
|
||||
{
|
||||
_editing = true;
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
async void OnCancelClicked()
|
||||
{
|
||||
_editing = false;
|
||||
|
||||
if(_creating)
|
||||
{
|
||||
NavigationManager.ToBaseRelativePath("admin/currency_inflation");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
_model = await Service.GetAsync(Id);
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
async void OnSaveClicked()
|
||||
{
|
||||
if(string.IsNullOrWhiteSpace(_model.CurrencyCode))
|
||||
return;
|
||||
|
||||
if(_model.Year > DateTime.UtcNow.Year)
|
||||
return;
|
||||
|
||||
if(_model.Inflation == 0)
|
||||
return;
|
||||
|
||||
if(_creating)
|
||||
Id = await Service.CreateAsync(_model, (await UserManager.GetUserAsync(_authState.User)).Id);
|
||||
else
|
||||
await Service.UpdateAsync(_model, (await UserManager.GetUserAsync(_authState.User)).Id);
|
||||
|
||||
_editing = false;
|
||||
_creating = false;
|
||||
_model = await Service.GetAsync(Id);
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
void ValidateYear(ValidatorEventArgs e)
|
||||
{
|
||||
e.Status = ValidationStatus.Success;
|
||||
|
||||
if((uint)e.Value <= DateTime.UtcNow.Year)
|
||||
return;
|
||||
|
||||
e.Status = ValidationStatus.Error;
|
||||
e.ErrorText = L["Year must be before current one."];
|
||||
}
|
||||
|
||||
void ValidateInflation(ValidatorEventArgs e)
|
||||
{
|
||||
e.Status = ValidationStatus.Success;
|
||||
|
||||
if((float)e.Value != 0)
|
||||
return;
|
||||
|
||||
e.Status = ValidationStatus.Error;
|
||||
e.ErrorText = L["Inflation must be bigger than 0."];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -99,4 +99,12 @@
|
||||
</div>
|
||||
<div class="content">
|
||||
<h3>@L["User administrative pages"]</h3>
|
||||
</div>
|
||||
</div>
|
||||
<div class="content">
|
||||
<h3>@L["Administrative pages for currencies"]</h3>
|
||||
<ul>
|
||||
<li>
|
||||
<a href="/admin/currency_inflation">@L["Currency inflation"]</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
@@ -14,4 +14,10 @@
|
||||
<data name="Books" xml:space="preserve">
|
||||
<value>Books</value>
|
||||
</data>
|
||||
<data name="Administrative pages for currencies" xml:space="preserve">
|
||||
<value>Administrative pages for currencies</value>
|
||||
</data>
|
||||
<data name="Currency inflation" xml:space="preserve">
|
||||
<value>Currency inflation</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -213,4 +213,10 @@
|
||||
<data name="Books" xml:space="preserve">
|
||||
<value>Libros</value>
|
||||
</data>
|
||||
<data name="Administrative pages for currencies" xml:space="preserve">
|
||||
<value>Páginas de administración para divisas</value>
|
||||
</data>
|
||||
<data name="Currency inflation" xml:space="preserve">
|
||||
<value>Inflación de divisa</value>
|
||||
</data>
|
||||
</root>
|
||||
74
Marechai/Resources/Services/CurrencyInflationService.en.resx
Normal file
74
Marechai/Resources/Services/CurrencyInflationService.en.resx
Normal file
@@ -0,0 +1,74 @@
|
||||
<root>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>1.3</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<data name="Currency inflation" xml:space="preserve">
|
||||
<value>Currency inflation</value>
|
||||
</data>
|
||||
<data name="Create new" xml:space="preserve">
|
||||
<value>Create new</value>
|
||||
</data>
|
||||
<data name="Loading..." xml:space="preserve">
|
||||
<value>Loading...</value>
|
||||
</data>
|
||||
<data name="Currency" xml:space="preserve">
|
||||
<value>Currency</value>
|
||||
</data>
|
||||
<data name="Year" xml:space="preserve">
|
||||
<value>Year</value>
|
||||
</data>
|
||||
<data name="Inflation" xml:space="preserve">
|
||||
<value>Inflation</value>
|
||||
</data>
|
||||
<data name="Details" xml:space="preserve">
|
||||
<value>Details</value>
|
||||
</data>
|
||||
<data name="Edit" xml:space="preserve">
|
||||
<value>Edit</value>
|
||||
</data>
|
||||
<data name="Delete" xml:space="preserve">
|
||||
<value>Delete</value>
|
||||
</data>
|
||||
<data name="Delete currency inflation" xml:space="preserve">
|
||||
<value>Delete currency inflation</value>
|
||||
</data>
|
||||
<data name="Are you sure you want to delete the inflation of {0:F} happened to currency {1} on {2}?" xml:space="preserve">
|
||||
<value>Are you sure you want to delete the inflation of {0:F} happened to currency {1} on {2}?</value>
|
||||
</data>
|
||||
<data name="Currency inflation details" xml:space="preserve">
|
||||
<value>Currency inflation details</value>
|
||||
</data>
|
||||
<data name="Please enter a valid year." xml:space="preserve">
|
||||
<value>Please enter a valid year.</value>
|
||||
</data>
|
||||
<data name="Inflation (ratio)" xml:space="preserve">
|
||||
<value>Inflation (ratio)</value>
|
||||
</data>
|
||||
<data name="Please enter a valid inflation." xml:space="preserve">
|
||||
<value>Please enter a valid inflation.</value>
|
||||
</data>
|
||||
<data name="Save" xml:space="preserve">
|
||||
<value>Save</value>
|
||||
</data>
|
||||
<data name="Cancel" xml:space="preserve">
|
||||
<value>Cancel</value>
|
||||
</data>
|
||||
<data name="Back to list" xml:space="preserve">
|
||||
<value>Back to list</value>
|
||||
</data>
|
||||
<data name="Year must be before current one." xml:space="preserve">
|
||||
<value>Year must be before current one.</value>
|
||||
</data>
|
||||
<data name="Inflation must be different than 0." xml:space="preserve">
|
||||
<value>Inflation must be different than 0.</value>
|
||||
</data>
|
||||
</root>
|
||||
181
Marechai/Resources/Services/CurrencyInflationService.es.resx
Normal file
181
Marechai/Resources/Services/CurrencyInflationService.es.resx
Normal file
@@ -0,0 +1,181 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- ReSharper disable MarkupTextTypo -->
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<data name="Currency inflation" xml:space="preserve">
|
||||
<value>Inflación de divisa</value>
|
||||
</data>
|
||||
<data name="Loading..." xml:space="preserve">
|
||||
<value>Cargando...</value>
|
||||
</data>
|
||||
<data name="Create new" xml:space="preserve">
|
||||
<value>Crear nueva</value>
|
||||
</data>
|
||||
<data name="Currency" xml:space="preserve">
|
||||
<value>Divisa</value>
|
||||
</data>
|
||||
<data name="Year" xml:space="preserve">
|
||||
<value>Año</value>
|
||||
</data>
|
||||
<data name="Inflation" xml:space="preserve">
|
||||
<value>Inflación</value>
|
||||
</data>
|
||||
<data name="Details" xml:space="preserve">
|
||||
<value>Detalles</value>
|
||||
</data>
|
||||
<data name="Edit" xml:space="preserve">
|
||||
<value>Editar</value>
|
||||
</data>
|
||||
<data name="Delete" xml:space="preserve">
|
||||
<value>Eliminar</value>
|
||||
</data>
|
||||
<data name="Delete currency inflation" xml:space="preserve">
|
||||
<value>Eliminar inflación de divisa</value>
|
||||
</data>
|
||||
<data name="Are you sure you want to delete the inflation of {0:F} happened to currency {1} on {2}?" xml:space="preserve">
|
||||
<value>¿Estás seguro de querer eliminar la inflación de {0:F} ocurrida a la divisa {2} en {3}</value>
|
||||
</data>
|
||||
<data name="Currency inflation details" xml:space="preserve">
|
||||
<value>Detalles de inflación de divisa</value>
|
||||
</data>
|
||||
<data name="Please enter a valid year." xml:space="preserve">
|
||||
<value>Por favor introduce un año válido.</value>
|
||||
</data>
|
||||
<data name="Inflation (ratio)" xml:space="preserve">
|
||||
<value>Inflación (relación)</value>
|
||||
</data>
|
||||
<data name="Please enter a valid inflation." xml:space="preserve">
|
||||
<value>Por favor introduce una inflación válida.</value>
|
||||
</data>
|
||||
<data name="Save" xml:space="preserve">
|
||||
<value>Guardar</value>
|
||||
</data>
|
||||
<data name="Cancel" xml:space="preserve">
|
||||
<value>Cancelar</value>
|
||||
</data>
|
||||
<data name="Back to list" xml:space="preserve">
|
||||
<value>Volver a la lista</value>
|
||||
</data>
|
||||
<data name="Year must be before current one." xml:space="preserve">
|
||||
<value>El año debe ser anterior al actual.</value>
|
||||
</data>
|
||||
<data name="Inflation must be different than 0." xml:space="preserve">
|
||||
<value>La inflación debe ser distinta de 0.</value>
|
||||
</data>
|
||||
</root>
|
||||
104
Marechai/Services/CurrencyInflationService.cs
Normal file
104
Marechai/Services/CurrencyInflationService.cs
Normal file
@@ -0,0 +1,104 @@
|
||||
/******************************************************************************
|
||||
// MARECHAI: Master repository of computing history artifacts information
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// --[ License ] --------------------------------------------------------------
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
// Copyright © 2003-2020 Natalia Portillo
|
||||
*******************************************************************************/
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Marechai.Database.Models;
|
||||
using Marechai.ViewModels;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Marechai.Services
|
||||
{
|
||||
public class CurrencyInflationService
|
||||
{
|
||||
readonly MarechaiContext _context;
|
||||
|
||||
public CurrencyInflationService(MarechaiContext context) => _context = context;
|
||||
|
||||
public async Task<List<CurrencyInflationViewModel>> GetAsync() => await _context.
|
||||
CurrenciesInflation.
|
||||
OrderBy(i => i.Currency.Name).
|
||||
ThenBy(i => i.Year).
|
||||
Select(i => new CurrencyInflationViewModel
|
||||
{
|
||||
Id = i.Id,
|
||||
CurrencyCode = i.Currency.Code,
|
||||
CurrencyName = i.Currency.Name,
|
||||
Year = i.Year,
|
||||
Inflation = i.Inflation
|
||||
}).ToListAsync();
|
||||
|
||||
public async Task<CurrencyInflationViewModel> GetAsync(int id) =>
|
||||
await _context.CurrenciesInflation.Where(b => b.Id == id).Select(i => new CurrencyInflationViewModel
|
||||
{
|
||||
Id = i.Id,
|
||||
CurrencyCode = i.Currency.Code,
|
||||
CurrencyName = i.Currency.Name,
|
||||
Year = i.Year,
|
||||
Inflation = i.Inflation
|
||||
}).FirstOrDefaultAsync();
|
||||
|
||||
public async Task UpdateAsync(CurrencyInflationViewModel viewModel, string userId)
|
||||
{
|
||||
CurrencyInflation model = await _context.CurrenciesInflation.FindAsync(viewModel.Id);
|
||||
|
||||
if(model is null)
|
||||
return;
|
||||
|
||||
model.CurrencyCode = viewModel.CurrencyCode;
|
||||
model.Year = viewModel.Year;
|
||||
model.Inflation = viewModel.Inflation;
|
||||
await _context.SaveChangesWithUserAsync(userId);
|
||||
}
|
||||
|
||||
public async Task<int> CreateAsync(CurrencyInflationViewModel viewModel, string userId)
|
||||
{
|
||||
var model = new CurrencyInflation
|
||||
{
|
||||
CurrencyCode = viewModel.CurrencyCode,
|
||||
Year = viewModel.Year,
|
||||
Inflation = viewModel.Inflation
|
||||
};
|
||||
|
||||
await _context.CurrenciesInflation.AddAsync(model);
|
||||
await _context.SaveChangesWithUserAsync(userId);
|
||||
|
||||
return model.Id;
|
||||
}
|
||||
|
||||
public async Task DeleteAsync(int id, string userId)
|
||||
{
|
||||
CurrencyInflation item = await _context.CurrenciesInflation.FindAsync(id);
|
||||
|
||||
if(item is null)
|
||||
return;
|
||||
|
||||
_context.CurrenciesInflation.Remove(item);
|
||||
|
||||
await _context.SaveChangesWithUserAsync(userId);
|
||||
}
|
||||
}
|
||||
}
|
||||
42
Marechai/Services/Iso4217Service.cs
Normal file
42
Marechai/Services/Iso4217Service.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
/******************************************************************************
|
||||
// MARECHAI: Master repository of computing history artifacts information
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// --[ License ] --------------------------------------------------------------
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
// Copyright © 2003-2020 Natalia Portillo
|
||||
*******************************************************************************/
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Marechai.Database.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Marechai.Services
|
||||
{
|
||||
public class Iso4217Service
|
||||
{
|
||||
readonly MarechaiContext _context;
|
||||
|
||||
public Iso4217Service(MarechaiContext context) => _context = context;
|
||||
|
||||
public async Task<List<Iso4217>> GetAsync() => await _context.Iso4217.OrderBy(c => c.Name).ToListAsync();
|
||||
}
|
||||
}
|
||||
@@ -68,6 +68,8 @@ namespace Marechai.Services
|
||||
services.AddScoped<ResolutionsByGpuService>();
|
||||
services.AddScoped<MachinePhotosService>();
|
||||
services.AddScoped<BooksService>();
|
||||
services.AddScoped<CurrencyInflationService>();
|
||||
services.AddScoped<Iso4217Service>();
|
||||
}
|
||||
}
|
||||
}
|
||||
35
Marechai/ViewModels/CurrencyInflationViewModel.cs
Normal file
35
Marechai/ViewModels/CurrencyInflationViewModel.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
/******************************************************************************
|
||||
// MARECHAI: Master repository of computing history artifacts information
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// --[ License ] --------------------------------------------------------------
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
// Copyright © 2003-2020 Natalia Portillo
|
||||
*******************************************************************************/
|
||||
|
||||
namespace Marechai.ViewModels
|
||||
{
|
||||
public class CurrencyInflationViewModel : BaseViewModel<int>
|
||||
{
|
||||
public string CurrencyCode { get; set; }
|
||||
public string CurrencyName { get; set; }
|
||||
public uint Year { get; set; }
|
||||
public float Inflation { get; set; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user