public async Task TM_UpdateConcepts_SATGroup()
        {
            var connectionString = ConfigManager.GetValue("ConfigConnectionStringTest");

            using var context = new CotorraContext(connectionString);
            Expression <Func <ConceptPayment, bool> > expression = exp => exp.Active;
            var conceptPayments = await context.ConceptPayment.Where(expression).ToListAsync();

            var memoryStorageContext = new MemoryStorageContext();
            var accumulateds         = memoryStorageContext.GetDefaultAccumulatedType(Guid.Empty, Guid.Empty, Guid.Empty);

            (var conceptPaymentsMemory, var pr) = memoryStorageContext.GetDefaultConcept <ConceptPayment>(Guid.Empty, Guid.Empty, Guid.Empty, accumulateds);

            conceptPayments.ForEach(conceptInDB =>
            {
                var conceptFoundInMemory = conceptPaymentsMemory
                                           .FirstOrDefault(p => p.Code == conceptInDB.Code && p.ConceptType == conceptInDB.ConceptType);
                if (null != conceptFoundInMemory)
                {
                    conceptInDB.SATGroupCode = conceptFoundInMemory.SATGroupCode;
                }
            });

            var concept22 = conceptPayments.AsParallel().Where(p => p.Code == 22 && p.ConceptType == ConceptType.SalaryPayment);

            context.UpdateRange(conceptPayments);
            await context.SaveChangesAsync();
        }
Example #2
0
        public async Task UpdateAsync(IEnumerable <Guid> idsToUpdate, CotorriaStatus status, Guid identityWorkID, params object[] parameters)
        {
            using var context = new CotorraContext(ConnectionManager.ConfigConnectionString);
            DateTime now      = DateTime.UtcNow;
            string   nowStrng = now.ToString("yyyy-mm-dd HH:mm:ss.fffffff");

            context.ChangeTracker.AutoDetectChangesEnabled = false;
            var keys        = idsToUpdate.Select(p => "'" + p + "'").ToArray();
            var keySplitted = String.Join(",", keys);
            var sql         = Validator.GetPersonalizedQuery(status, keySplitted, parameters);

            if (string.IsNullOrEmpty(sql))
            {
                sql = $"update   {typeof(T).Name} set LocalStatus = {(int)status}, LastStatusChange = getdate()  where ID in ({keySplitted}) ";
            }
            var row = await context.Database.ExecuteSqlRawAsync(sql);

            await context.SaveChangesAsync();
        }
 /// <summary>
 /// Delete things
 /// </summary>
 /// <param name="lstObjects"></param>
 /// <param name="identityWorkId"></param>
 public void Delete(List <Guid> lstObjects, Guid identityWorkId)
 {
     using var context     = new CotorraContext(ConnectionManager.ConfigConnectionString);
     using var iRepository = new RepositoryStorage <T, CotorraContext>(context, true);
     iRepository.Delete(lstObjects, identityWorkId);
 }
 public async Task <int> CountAsync(string predicate, Guid identityWorkId)
 {
     using var context     = new CotorraContext(ConnectionManager.ConfigConnectionString);
     using var iRepository = new RepositoryStorage <T, CotorraContext>(context, true);
     return(await iRepository.GetCountAsync(predicate, identityWorkID : identityWorkId));
 }
 public int Count(Expression <Func <T, bool> > predicate, Guid identityWorkId)
 {
     using var context     = new CotorraContext(ConnectionManager.ConfigConnectionString);
     using var iRepository = new RepositoryStorage <T, CotorraContext>(context, true);
     return(iRepository.GetCount(predicate, identityWorkID: identityWorkId));
 }
 public async Task CreateorUpdateAsync(List <T> objectsToCreate, Guid identityWorkID)
 {
     using var context     = new CotorraContext(ConnectionManager.ConfigConnectionString);
     using var iRepository = new RepositoryStorage <T, CotorraContext>(context, true);
     await iRepository.CreateorUpdateAsync(objectsToCreate, identityWorkID);
 }
 public async Task UpdateAsync(List <T> lstObjects, Guid identityWorkId)
 {
     using var context     = new CotorraContext(ConnectionManager.ConfigConnectionString);
     using var iRepository = new RepositoryStorage <T, CotorraContext>(context, true);
     await iRepository.UpdateAsync(lstObjects, identityWorkId);
 }
 public List <T> GetAll(Guid identityWorkId, string[] objectsToInclude)
 {
     using var context     = new CotorraContext(ConnectionManager.ConfigConnectionString);
     using var iRepository = new RepositoryStorage <T, CotorraContext>(context, true);
     return(iRepository.FindAll(identityWorkID: identityWorkId).ToList());
 }
 public async Task <List <T> > FindAsync(Expression <Func <T, bool> > predicate, Guid identityWorkId, string[] objectsToInclude)
 {
     using var context     = new CotorraContext(ConnectionManager.ConfigConnectionString);
     using var iRepository = new RepositoryStorage <T, CotorraContext>(context, true);
     return(await iRepository.FindAsync(predicate, identityWorkID : identityWorkId, objectsToInclude : objectsToInclude));
 }
 public async Task <List <T> > GetByIdsAsync(List <Guid> lstGuids, Guid identityWorkId, string[] objectsToInclude)
 {
     using var context     = new CotorraContext(ConnectionManager.ConfigConnectionString);
     using var iRepository = new RepositoryStorage <T, CotorraContext>(context, true);
     return((await iRepository.GetByIdsAsync(lstGuids, identityWorkID: identityWorkId, objectsToInclude: objectsToInclude)).Select(p => p.Value).ToList());
 }