Fix delete dossier sistemato...
This commit is contained in:
@@ -735,29 +735,18 @@ namespace MP.Data.Controllers
|
||||
/// </summary>
|
||||
/// <param name="currRec">record dossier da eliminare</param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> DossiersDeleteRecord(DossierModel currRec)
|
||||
public async Task<bool> DossiersDeleteRecordAsync(DossierModel currRec)
|
||||
{
|
||||
bool answ = false;
|
||||
using (var dbCtx = new MoonPro_FluxContext(_configuration))
|
||||
{
|
||||
try
|
||||
{
|
||||
var currVal = dbCtx
|
||||
using var dbCtx = new MoonPro_FluxContext(_configuration);
|
||||
var currVal = await dbCtx
|
||||
.DbSetDossiers
|
||||
.Where(x => x.IdxDossier == currRec.IdxDossier)
|
||||
.FirstOrDefault();
|
||||
dbCtx
|
||||
.DbSetDossiers
|
||||
.Remove(currVal);
|
||||
await dbCtx.SaveChangesAsync();
|
||||
answ = true;
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Eccezione durante DossiersDeleteRecord{Environment.NewLine}{exc}");
|
||||
}
|
||||
}
|
||||
return answ;
|
||||
.FirstOrDefaultAsync();
|
||||
dbCtx
|
||||
.DbSetDossiers
|
||||
.Remove(currVal);
|
||||
|
||||
return await dbCtx.SaveChangesAsync() > 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -261,7 +261,7 @@ else
|
||||
@if (isEditing == false)
|
||||
{
|
||||
|
||||
<button @onclick="() => deleteRecord(record)" class="btn btn-danger btn-sm"><i class="bi bi-trash-fill"></i></button>
|
||||
<button @onclick="() => DoDelete(record)" class="btn btn-danger btn-sm"><i class="bi bi-trash-fill"></i></button>
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -146,16 +146,15 @@ namespace MP.SPEC.Components
|
||||
/// </summary>
|
||||
/// <param name="selRec"></param>
|
||||
/// <returns></returns>
|
||||
protected async Task deleteRecord(DossierModel selRec)
|
||||
protected async Task DoDelete(DossierModel selRec)
|
||||
{
|
||||
if (!await JSRuntime.InvokeAsync<bool>("confirm", "Eliminazione Dossier: sei sicuro di voler procedere?"))
|
||||
return;
|
||||
await Task.Delay(1);
|
||||
var done = await MDService.DossiersDeleteRecord(selRec);
|
||||
|
||||
var done = await MDService.DossiersDeleteRecordAsync(selRec);
|
||||
currRecord = null;
|
||||
await ReloadData(true);
|
||||
visualizzaFlux = true;
|
||||
await Task.Delay(1);
|
||||
}
|
||||
|
||||
protected async Task editRecord(FluxLogDTO selRec)
|
||||
|
||||
@@ -548,17 +548,18 @@ namespace MP.SPEC.Data
|
||||
/// </summary>
|
||||
/// <param name="selRecord">record dossier da eliminare</param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> DossiersDeleteRecord(DossierModel selRecord)
|
||||
public async Task<bool> DossiersDeleteRecordAsync(DossierModel selRecord)
|
||||
{
|
||||
using var activity = ActivitySource.StartActivity("DossiersDeleteRecord");
|
||||
using var activity = ActivitySource.StartActivity("DossiersDeleteRecordAsync");
|
||||
bool result = false;
|
||||
result = await dbController.DossiersDeleteRecord(selRecord);
|
||||
result = await dbController.DossiersDeleteRecordAsync(selRecord);
|
||||
// elimino cache redis...
|
||||
RedisValue pattern = new RedisValue($"{Utils.redisDossByMac}:*");
|
||||
bool answ = await ExecFlushRedisPatternAsync(pattern);
|
||||
activity?.SetTag("data.source", "DB+REDIS");
|
||||
//RedisValue pattern = new RedisValue($"{Utils.redisDossByMac}:*");
|
||||
//bool answ = await ExecFlushRedisPatternAsync(pattern);
|
||||
await FlushCacheByTagAsync(Utils.redisDossByMac);
|
||||
activity?.SetTag("data.source", "DB");
|
||||
activity?.Stop();
|
||||
LogTrace($"DossiersDeleteRecord | IdxMacchina {selRecord.IdxMacchina} | DtRif {selRecord.DtRif} | IdxODL {selRecord.IdxODL} | {activity?.Duration.TotalMilliseconds}ms");
|
||||
LogTrace($"DossiersDeleteRecordAsync | IdxMacchina {selRecord.IdxMacchina} | DtRif {selRecord.DtRif} | IdxODL {selRecord.IdxODL} | {activity?.Duration.TotalMilliseconds}ms");
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user