50d65eebaa
- renaming classi gestione DbModels in - spostamento anagrafica flussi da auth a generale
160 lines
4.6 KiB
C#
160 lines
4.6 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
using Microsoft.AspNetCore.Components;
|
|
using System.Net.Http;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Components.Authorization;
|
|
using Microsoft.AspNetCore.Components.Forms;
|
|
using Microsoft.AspNetCore.Components.Routing;
|
|
using Microsoft.AspNetCore.Components.Web;
|
|
using Microsoft.AspNetCore.Components.Web.Virtualization;
|
|
using Microsoft.JSInterop;
|
|
using MP.INVE;
|
|
using MP.INVE.Shared;
|
|
using MP.INVE.Components;
|
|
using Blazored.LocalStorage;
|
|
using Blazored.SessionStorage;
|
|
using MP.Data.DbModels;
|
|
using MP.INVE.Data;
|
|
|
|
namespace MP.INVE.Components
|
|
{
|
|
public partial class MagList
|
|
{
|
|
[Inject]
|
|
private IConfiguration Configuration { get; set; } = null!;
|
|
|
|
[Inject]
|
|
private ISessionStorageService sessionStorage { get; set; } = null!;
|
|
[Inject]
|
|
private ILocalStorageService localStorage { get; set; } = null!;
|
|
|
|
[Inject]
|
|
private MiDataService MIDataservice { get; set; } = null!;
|
|
|
|
[Inject]
|
|
private NavigationManager NavManager { get; set; } = null!;
|
|
|
|
[Inject]
|
|
private IJSRuntime JSRuntime { get; set; } = null!;
|
|
|
|
[Parameter]
|
|
public SelectMagListParams currParams { get; set; } = null!;
|
|
|
|
[Parameter]
|
|
public bool isLoading { get; set; }
|
|
|
|
protected override async Task OnParametersSetAsync()
|
|
{
|
|
await reloadData();
|
|
}
|
|
private void closeNew()
|
|
{
|
|
reqNew = false;
|
|
codMag = "";
|
|
mod = false;
|
|
desc = "";
|
|
}
|
|
private List<AnagMagModel>? ElencoMagazzini;
|
|
private List<AnagMagModel>? SearchRecords;
|
|
private AnagMagModel currMag { get; set; } = null!;
|
|
private bool mod { get; set; } = false;
|
|
private async Task insertNewMag()
|
|
{
|
|
var alert = await JSRuntime.InvokeAsync<bool>("confirm", "Confermi di voler creare un nuovo magazzino?");
|
|
|
|
if (alert)
|
|
{
|
|
AnagMagModel newMag = new AnagMagModel()
|
|
{
|
|
CodMag = codMag,
|
|
CodCS = "EC",
|
|
DescMag = desc,
|
|
Nascosto = false
|
|
};
|
|
await MIDataservice.InsertNewMag(newMag);
|
|
NavManager.NavigateTo(NavManager.Uri, true);
|
|
//await MIDataservice.FlushRedisCache();
|
|
await reloadData();
|
|
}
|
|
else
|
|
{
|
|
closeNew();
|
|
}
|
|
}
|
|
|
|
private async Task reloadData()
|
|
{
|
|
isLoading = true;
|
|
ElencoMagazzini = null;
|
|
SearchRecords = null;
|
|
SearchRecords = MIDataservice.MagazziniList();
|
|
totalCount = SearchRecords.Count;
|
|
ElencoMagazzini = SearchRecords.Skip(numRecord * (currPage - 1)).Take(numRecord).ToList();
|
|
await Task.Delay(1);
|
|
await InvokeAsync(() => StateHasChanged());
|
|
await Task.Delay(1);
|
|
isLoading = false;
|
|
}
|
|
private async Task modMag(AnagMagModel mag)
|
|
{
|
|
var alert = await JSRuntime.InvokeAsync<bool>("confirm", "Confermi di voler modificare il magazzino selezionato?");
|
|
if (alert)
|
|
{
|
|
|
|
await MIDataservice.UpdateMag(currMag);
|
|
NavManager.NavigateTo(NavManager.Uri, true);
|
|
await reloadData();
|
|
}
|
|
else
|
|
{
|
|
closeNew();
|
|
}
|
|
}
|
|
private async Task reqModMag(AnagMagModel mag)
|
|
{
|
|
await Task.Delay(1);
|
|
mod = true;
|
|
reqNew = true;
|
|
currMag = mag;
|
|
}
|
|
private bool reqNew
|
|
{
|
|
get => currParams.reqNew;
|
|
set => currParams.reqNew = value;
|
|
}
|
|
|
|
private int totalCount
|
|
{
|
|
get => currParams.TotCount;
|
|
set => currParams.TotCount = value;
|
|
}
|
|
private int numRecord
|
|
{
|
|
get => currParams.NumRec;
|
|
set
|
|
{
|
|
currParams.NumRec = value;
|
|
StateHasChanged();
|
|
}
|
|
}
|
|
private int currPage
|
|
{
|
|
get => currParams.CurrPage;
|
|
set
|
|
{
|
|
currParams.CurrPage = value;
|
|
StateHasChanged();
|
|
}
|
|
}
|
|
private bool inCorso
|
|
{
|
|
get => currParams.inCorso;
|
|
set => currParams.inCorso = value;
|
|
}
|
|
private string codMag { get; set; } = "";
|
|
private string desc { get; set; } = "";
|
|
}
|
|
} |