Completata pagina confronto AnagKeyVal, da estendere!
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using MP.AppAuth.Models;
|
||||
using NLog;
|
||||
using System;
|
||||
@@ -42,6 +43,58 @@ namespace MP.AppAuth.Controllers
|
||||
}
|
||||
return dbResult;
|
||||
}
|
||||
/// <summary>
|
||||
/// Elenco Record x AnagKeyValue
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool AnagKeyValuesDelete(string NomeVar)
|
||||
{
|
||||
bool fatto = false;
|
||||
using (MoonProContext localDbCtx = new MoonProContext(_configuration))
|
||||
{
|
||||
var rec2del = localDbCtx
|
||||
.DbSetAnagKeyValues
|
||||
.Where(x => x.NomeVar == NomeVar)
|
||||
.FirstOrDefault();
|
||||
if (rec2del != null)
|
||||
{
|
||||
localDbCtx.Remove(rec2del);
|
||||
var res = localDbCtx.SaveChanges();
|
||||
fatto = res > 0;
|
||||
}
|
||||
}
|
||||
return fatto;
|
||||
}
|
||||
/// <summary>
|
||||
/// Upsert AnagKeyValue
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool AnagKeyValuesUpsert(AnagKeyValueModel newRec)
|
||||
{
|
||||
bool fatto = false;
|
||||
using (MoonProContext localDbCtx = new MoonProContext(_configuration))
|
||||
{
|
||||
var currRec = localDbCtx
|
||||
.DbSetAnagKeyValues
|
||||
.Where(x => x.NomeVar == newRec.NomeVar)
|
||||
.FirstOrDefault();
|
||||
if (currRec != null)
|
||||
{
|
||||
currRec.Descrizione = newRec.Descrizione;
|
||||
currRec.ValInt = newRec.ValInt;
|
||||
currRec.ValFloat = newRec.ValFloat;
|
||||
currRec.ValString = newRec.ValString;
|
||||
localDbCtx.Entry(currRec).State = EntityState.Modified;
|
||||
}
|
||||
else
|
||||
{
|
||||
localDbCtx.DbSetAnagKeyValues.Add(newRec);
|
||||
}
|
||||
var res = localDbCtx.SaveChanges();
|
||||
fatto = res > 0;
|
||||
}
|
||||
return fatto;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elenco Record x Config
|
||||
|
||||
Reference in New Issue
Block a user