diff --git a/MP.Data/Controllers/MpMonController.cs b/MP.Data/Controllers/MpMonController.cs
index c58f056c..4d13053b 100644
--- a/MP.Data/Controllers/MpMonController.cs
+++ b/MP.Data/Controllers/MpMonController.cs
@@ -10,14 +10,6 @@ namespace MP.Data.Controllers
{
public class MpMonController : IDisposable
{
- #region Private Fields
-
- private static IConfiguration _configuration;
-
- private static NLog.Logger Log = LogManager.GetCurrentClassLogger();
-
- #endregion Private Fields
-
#region Public Constructors
public MpMonController(IConfiguration configuration)
@@ -52,6 +44,24 @@ namespace MP.Data.Controllers
return dbResult;
}
+ ///
+ /// Elenco da tabella Macchine
+ ///
+ ///
+ public List ConfigGetAll()
+ {
+ List dbResult = new List();
+ using (var dbCtx = new MoonProContext(_configuration))
+ {
+ dbResult = dbCtx
+ .DbSetConfig
+ .AsNoTracking()
+ .OrderBy(x => x.Chiave)
+ .ToList();
+ }
+ return dbResult;
+ }
+
public void Dispose()
{
}
@@ -74,24 +84,6 @@ namespace MP.Data.Controllers
return dbResult;
}
- ///
- /// Elenco da tabella Macchine
- ///
- ///
- public List ConfigGetAll()
- {
- List dbResult = new List();
- using (var dbCtx = new MoonProContext(_configuration))
- {
- dbResult = dbCtx
- .DbSetConfig
- .AsNoTracking()
- .OrderBy(x => x.Chiave)
- .ToList();
- }
- return dbResult;
- }
-
///
/// Elenco da tabella MappaStatoExpl
///
@@ -138,5 +130,13 @@ namespace MP.Data.Controllers
}
#endregion Public Methods
+
+ #region Private Fields
+
+ private static IConfiguration _configuration;
+
+ private static NLog.Logger Log = LogManager.GetCurrentClassLogger();
+
+ #endregion Private Fields
}
}
\ No newline at end of file
diff --git a/MP.Data/Controllers/MpSpecController.cs b/MP.Data/Controllers/MpSpecController.cs
index d4d44045..a6517d56 100644
--- a/MP.Data/Controllers/MpSpecController.cs
+++ b/MP.Data/Controllers/MpSpecController.cs
@@ -5,6 +5,7 @@ using NLog;
using System;
using System.Collections.Generic;
using System.Linq;
+using System.Threading.Tasks;
namespace MP.Data.Controllers
{
@@ -31,6 +32,8 @@ namespace MP.Data.Controllers
return AnagGruppiGetTipo("AZIENDA");
}
+
+
///
/// Elenco Gruppi
///
@@ -91,6 +94,77 @@ namespace MP.Data.Controllers
return dbResult;
}
+
+ ///
+ /// Eliminazione Record
+ ///
+ ///
+ ///
+ public async Task ArticoliDeleteRecord(DatabaseModels.AnagArticoli currRec)
+ {
+ bool fatto = false;
+ using (var dbCtx = new MoonProContext(_configuration))
+ {
+ try
+ {
+ var currVal = dbCtx
+ .DbSetArticoli
+ .Where(x => x.CodArticolo == currRec.CodArticolo)
+ .FirstOrDefault();
+ dbCtx
+ .DbSetArticoli
+ .Remove(currVal);
+ await dbCtx.SaveChangesAsync();
+ fatto = true;
+ }
+ catch (Exception exc)
+ {
+ Log.Error($"Eccezione durante ArticoliDeleteRecord{Environment.NewLine}{exc}");
+ }
+ }
+ return fatto;
+ }
+ ///
+ /// Update Record
+ ///
+ ///
+ ///
+ public async Task ArticoliUpdateRecord(DatabaseModels.AnagArticoli editRec)
+ {
+ bool fatto = false;
+ using (var dbCtx = new MoonProContext(_configuration))
+ {
+ try
+ {
+ var currRec = dbCtx
+ .DbSetArticoli
+ .Where(x => x.CodArticolo == editRec.CodArticolo)
+ .FirstOrDefault();
+ if (currRec != null)
+ {
+ currRec.Disegno = editRec.Disegno;
+ currRec.DescArticolo = editRec.DescArticolo;
+ currRec.Tipo = editRec.Tipo;
+ currRec.Azienda = editRec.Azienda;
+ dbCtx.Entry(currRec).State = EntityState.Modified;
+ }
+ else
+ {
+ dbCtx
+ .DbSetArticoli
+ .Add(editRec);
+ }
+ await dbCtx.SaveChangesAsync();
+ fatto = true;
+ }
+ catch (Exception exc)
+ {
+ Log.Error($"Eccezione durante ArticoliUpdateRecord{Environment.NewLine}{exc}");
+ }
+ }
+ return fatto;
+ }
+
///
/// Elenco tabella Articoli da filtro
///
diff --git a/MP.Data/DatabaseModels/AnagArticoli.cs b/MP.Data/DatabaseModels/AnagArticoli.cs
index ed8e5c3e..a3e6bddd 100644
--- a/MP.Data/DatabaseModels/AnagArticoli.cs
+++ b/MP.Data/DatabaseModels/AnagArticoli.cs
@@ -1,10 +1,12 @@
using System;
using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations.Schema;
#nullable disable
namespace MP.Data.DatabaseModels
{
+ [Table("AnagArticoli")]
public partial class AnagArticoli
{
#region Public Properties
diff --git a/MP.Data/MoonProContext.cs b/MP.Data/MoonProContext.cs
index 93db85e8..2b58026a 100644
--- a/MP.Data/MoonProContext.cs
+++ b/MP.Data/MoonProContext.cs
@@ -76,7 +76,7 @@ namespace MP.Data
modelBuilder.Entity(entity =>
{
- entity.HasNoKey();
+ entity.HasKey(e => e.CodArticolo);
entity.ToView("v_UI_AnagArticoli");
@@ -98,7 +98,7 @@ namespace MP.Data
});
modelBuilder.Entity(entity =>
{
- entity.HasNoKey();
+ entity.HasKey(e => e.CodArticolo);
entity.ToView("AnagArticoli");
@@ -125,7 +125,7 @@ namespace MP.Data
modelBuilder.Entity(entity =>
{
- entity.HasNoKey();
+ entity.HasKey(e => e.IdxMacchina);
entity.ToView("Macchine");
@@ -263,8 +263,6 @@ namespace MP.Data
{
entity.HasKey(e => e.CodGruppo);
- //entity.ToTable("AnagraficaGruppi");
-
entity.Property(e => e.CodGruppo)
.HasMaxLength(50)
.HasColumnName("CodGruppo");