public async Task <bool> TestDbConnection() { try { var optionsBuilder = new DbContextOptionsBuilder <KntDbContext>(); if (_repositoryRef.Provider == "Microsoft.Data.SqlClient") { optionsBuilder.UseSqlServer(_repositoryRef.ConnectionString); } else if (_repositoryRef.Provider == "Microsoft.Data.Sqlite") { optionsBuilder.UseSqlite(_repositoryRef.ConnectionString); optionsBuilder.ConfigureWarnings(x => x.Ignore(RelationalEventId.AmbientTransactionWarning)); } else { return(false); } var dbContext = new KntDbContext(optionsBuilder.Options, false); var systemValues = new KntSystemValuesRepository(dbContext, _repositoryRef); var res = await systemValues.GetAllAsync(); if (!res.IsValid) { return(false); } } catch (Exception) { return(false); } return(true); }
public virtual async Task <bool> CloseIsTempConnection(KntDbContext db) { try { if (SingletonConnection == null) { await db.DisposeAsync(); return(true); } else { return(false); } } catch (Exception) { return(false); } }
public KntNoteTypeRepository(KntDbContext singletonContext, RepositoryRef repositoryRef) : base(singletonContext, repositoryRef) { }
public KntRepository(KntDbContext singletonContext) { _context = singletonContext; }
public KntSystemValuesRepository(KntDbContext singletonContext, RepositoryRef repositoryRef) : base(singletonContext, repositoryRef) { }
private async Task <Result <KAttributeTabulatedValueDto> > SaveTabulateValueAsync(KntDbContext ctx, Guid attributeId, KAttributeTabulatedValueDto entity) { Result <KAttributeTabulatedValue> resRep = null; var resService = new Result <KAttributeTabulatedValueDto>(); try { var kattributeTabulatedValues = new GenericRepositoryEF <KntDbContext, KAttributeTabulatedValue>(ctx); if (entity.KAttributeTabulatedValueId == Guid.Empty) { entity.KAttributeTabulatedValueId = Guid.NewGuid(); var newEntity = new KAttributeTabulatedValue(); newEntity.SetSimpleDto(entity); newEntity.KAttributeId = attributeId; resRep = await kattributeTabulatedValues.AddAsync(newEntity); } else { var entityForUpdate = kattributeTabulatedValues.Get(entity.KAttributeTabulatedValueId).Entity; if (entityForUpdate != null) { entityForUpdate.SetSimpleDto(entity); resRep = await kattributeTabulatedValues.UpdateAsync(entityForUpdate); } else { var newEntity = new KAttributeTabulatedValue(); newEntity.SetSimpleDto(entity); newEntity.KAttributeId = attributeId; resRep = await kattributeTabulatedValues.AddAsync(newEntity); } } } catch (Exception ex) { AddExecptionsMessagesToErrorsList(ex, resService.ErrorList); } resService.Entity = resRep.Entity?.GetSimpleDto <KAttributeTabulatedValueDto>(); resService.ErrorList = resRep.ErrorList; return(ResultDomainAction(resService)); }
private async Task DeleteNoContainsTabulateValueAsync(KntDbContext ctx, Guid attributeId, List <Guid> guids) { var kattributeTabulatedValues = new GenericRepositoryEF <KntDbContext, KAttributeTabulatedValue>(ctx); var tabValuesForDelete = (await kattributeTabulatedValues.GetAllAsync(v => (v.KAttributeId == attributeId && !guids.Contains(v.KAttributeTabulatedValueId)))).Entity; var res = kattributeTabulatedValues.DeleteRange(tabValuesForDelete); }
public KntKAttributeRepository(KntDbContext singletonContext, RepositoryRef repositoryRef) : base(singletonContext, repositoryRef) { }
public KntRepositoryBase(KntDbContext singletonConnection, RepositoryRef repositoryRef) { SingletonConnection = singletonConnection; _repositoryRef = repositoryRef; _repositoryRef.ConnectionString = singletonConnection.Database.GetConnectionString(); }
public KntFolderRepository(KntDbContext singletonContext, RepositoryRef repositoryRef) : base(singletonContext, repositoryRef) { }