Aggiunta repository x Glass, Profile, Wood e servizi (da integrare)

This commit is contained in:
Samuele Locatelli
2026-03-16 18:47:16 +01:00
parent ac6695e7b0
commit 8195f63702
42 changed files with 1016 additions and 358 deletions
@@ -0,0 +1,54 @@
using EgwCoreLib.Lux.Data.DbModel.Config;
using Microsoft.EntityFrameworkCore;
namespace EgwCoreLib.Lux.Data.Repository.Config
{
public class ConfProfileRepository : BaseRepository, IConfProfileRepository
{
#region Public Constructors
public ConfProfileRepository(DataLayerContext db) : base(db)
{
}
#endregion Public Constructors
#region Public Methods
public void Add(ProfileModel entity) => _dbCtx.DbSetConfProfile.Add(entity);
public void Delete(ProfileModel entity) => _dbCtx.DbSetConfProfile.Remove(entity);
public async Task<List<ProfileModel>> GetAllAsync()
{
return await _dbCtx.DbSetConfProfile
.AsNoTracking()
.ToListAsync();
}
public async Task<ProfileModel?> GetByIdAsync(int recId)
{
return await _dbCtx.DbSetConfProfile
.Where(x => x.ProfileID == recId)
.FirstOrDefaultAsync();
}
public void Update(ProfileModel entity)
{
// Recuperiamo l'entità tracciata dal context
var trackedEntity = _dbCtx.DbSetConfProfile.Local.FirstOrDefault(x => x.ProfileID == entity.ProfileID);
if (trackedEntity != null)
{
// Aggiorna i valori dell'entità tracciata con quelli della nuova
_dbCtx.Entry(trackedEntity).CurrentValues.SetValues(entity);
}
else
{
_dbCtx.DbSetConfProfile.Update(entity);
}
}
#endregion Public Methods
}
}