Abbozzato edit config, da testare!
This commit is contained in:
@@ -29,22 +29,7 @@ namespace MP.AppAuth.Controllers
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
/// Elenco Record x AnagKeyValue
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public List<AnagKeyValueModel> AnagKeyValuesGetAll()
|
||||
{
|
||||
List<AnagKeyValueModel> dbResult = new List<AnagKeyValueModel>();
|
||||
using (MoonProContext localDbCtx = new MoonProContext(_configuration))
|
||||
{
|
||||
dbResult = localDbCtx
|
||||
.DbSetAnagKeyValues
|
||||
.ToList();
|
||||
}
|
||||
return dbResult;
|
||||
}
|
||||
/// <summary>
|
||||
/// Elenco Record x AnagKeyValue
|
||||
/// Delete Record AnagKeyValue
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool AnagKeyValuesDelete(string NomeVar)
|
||||
@@ -65,6 +50,23 @@ namespace MP.AppAuth.Controllers
|
||||
}
|
||||
return fatto;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elenco Record x AnagKeyValue
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public List<AnagKeyValueModel> AnagKeyValuesGetAll()
|
||||
{
|
||||
List<AnagKeyValueModel> dbResult = new List<AnagKeyValueModel>();
|
||||
using (MoonProContext localDbCtx = new MoonProContext(_configuration))
|
||||
{
|
||||
dbResult = localDbCtx
|
||||
.DbSetAnagKeyValues
|
||||
.ToList();
|
||||
}
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Upsert AnagKeyValue
|
||||
/// </summary>
|
||||
@@ -96,6 +98,29 @@ namespace MP.AppAuth.Controllers
|
||||
return fatto;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Delete Record Config
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool ConfigDelete(string Chiave)
|
||||
{
|
||||
bool fatto = false;
|
||||
using (MoonProContext localDbCtx = new MoonProContext(_configuration))
|
||||
{
|
||||
var rec2del = localDbCtx
|
||||
.DbSetConfig
|
||||
.Where(x => x.Chiave == Chiave)
|
||||
.FirstOrDefault();
|
||||
if (rec2del != null)
|
||||
{
|
||||
localDbCtx.Remove(rec2del);
|
||||
var res = localDbCtx.SaveChanges();
|
||||
fatto = res > 0;
|
||||
}
|
||||
}
|
||||
return fatto;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elenco Record x Config
|
||||
/// </summary>
|
||||
@@ -112,6 +137,36 @@ namespace MP.AppAuth.Controllers
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Upsert Config
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool ConfigUpsert(ConfigModel newRec)
|
||||
{
|
||||
bool fatto = false;
|
||||
using (MoonProContext localDbCtx = new MoonProContext(_configuration))
|
||||
{
|
||||
var currRec = localDbCtx
|
||||
.DbSetConfig
|
||||
.Where(x => x.Chiave == newRec.Chiave)
|
||||
.FirstOrDefault();
|
||||
if (currRec != null)
|
||||
{
|
||||
currRec.Valore = newRec.Valore;
|
||||
currRec.ValoreStd = newRec.ValoreStd;
|
||||
currRec.Note = newRec.Note;
|
||||
localDbCtx.Entry(currRec).State = EntityState.Modified;
|
||||
}
|
||||
else
|
||||
{
|
||||
localDbCtx.DbSetConfig.Add(newRec);
|
||||
}
|
||||
var res = localDbCtx.SaveChanges();
|
||||
fatto = res > 0;
|
||||
}
|
||||
return fatto;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if (dbController != null)
|
||||
@@ -121,6 +176,29 @@ namespace MP.AppAuth.Controllers
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Delete Record Vocabolario
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool VocabolarioDelete(VocabolarioModel currRec)
|
||||
{
|
||||
bool fatto = false;
|
||||
using (MoonProContext localDbCtx = new MoonProContext(_configuration))
|
||||
{
|
||||
var rec2del = localDbCtx
|
||||
.DbSetVocabolario
|
||||
.Where(x => x.Lingua == currRec.Lingua && x.Lemma == currRec.Lemma)
|
||||
.FirstOrDefault();
|
||||
if (rec2del != null)
|
||||
{
|
||||
localDbCtx.Remove(rec2del);
|
||||
var res = localDbCtx.SaveChanges();
|
||||
fatto = res > 0;
|
||||
}
|
||||
}
|
||||
return fatto;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elenco Record x VocabolarioModel
|
||||
/// </summary>
|
||||
@@ -137,6 +215,34 @@ namespace MP.AppAuth.Controllers
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Upsert Vocabolario
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool VocabolarioUpsert(VocabolarioModel newRec)
|
||||
{
|
||||
bool fatto = false;
|
||||
using (MoonProContext localDbCtx = new MoonProContext(_configuration))
|
||||
{
|
||||
var currRec = localDbCtx
|
||||
.DbSetVocabolario
|
||||
.Where(x => x.Lingua == newRec.Lingua && x.Lemma == newRec.Lemma)
|
||||
.FirstOrDefault();
|
||||
if (currRec != null)
|
||||
{
|
||||
currRec.Traduzione = newRec.Traduzione;
|
||||
localDbCtx.Entry(currRec).State = EntityState.Modified;
|
||||
}
|
||||
else
|
||||
{
|
||||
localDbCtx.DbSetVocabolario.Add(newRec);
|
||||
}
|
||||
var res = localDbCtx.SaveChanges();
|
||||
fatto = res > 0;
|
||||
}
|
||||
return fatto;
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#region Private Fields
|
||||
|
||||
Reference in New Issue
Block a user