using Microsoft.EntityFrameworkCore; using MP.Data.DbModels.Mtc; using MP.Data.Repository.Utils; using System.Threading.Tasks; namespace MP.Data.Repository.Mtc { public class MtcSetupRepository : BaseRepository, IMtcSetupRepository { #region Public Constructors public MtcSetupRepository(IDbContextFactory ctxFactory) : base(ctxFactory) { } #endregion Public Constructors #region Public Methods /// public async Task DeleteAsync(string idxMacchina) { bool actRes = false; await using var dbCtx = await CreateContextAsync(); var existing = await GetByIdxAsync(idxMacchina); if (existing != null) { dbCtx.DbSetMtcSetup.Remove(existing); actRes = await dbCtx.SaveChangesAsync() > 0; } return actRes; } /// public async Task GetByIdxAsync(string idxMacchina) { await using var dbCtx = await CreateContextAsync(); return await dbCtx.DbSetMtcSetup //.Include(s => s.MtcDataItems) .FirstOrDefaultAsync(s => s.IdxMacchina == idxMacchina); } /// public async Task InsertAsync(MtcSetupModel newRec) { bool actRes = false; await using var dbCtx = await CreateContextAsync(); dbCtx.DbSetMtcSetup.Add(newRec); actRes = await dbCtx.SaveChangesAsync() > 0; return actRes; } /// public async Task UpdateAsync(MtcSetupModel updRec) { bool actRes = false; await using var dbCtx = await CreateContextAsync(); dbCtx.DbSetMtcSetup.Update(updRec); actRes = await dbCtx.SaveChangesAsync() > 0; return actRes; } #endregion Public Methods } }