public async Task UpdateImageLinksInText() { var sqliteFile = @"C:\Users\Oleksii.Mamikonian\source\repos\Db\DbRiseDiary.db"; var connStr = $@"Data Source={sqliteFile};"; IConfigurationRoot configuration = new ConfigurationBuilder().Build(); var builder = new DbContextOptionsBuilder <DiaryDbContext>(); builder.UseSqlite(connStr); using var context = new DiaryDbContext(builder.Options); context.Database.Migrate(); var allRecords = context.Records.Include(r => r.Cogitations).AsAsyncEnumerable(); await foreach (var rec in allRecords) { var newText = rec.Text.Replace(@"/Images/ImageFile/", @"/api/v1.0/image-file/", true, null); rec.Text = newText; foreach (var cog in rec.Cogitations) { var newCogText = cog.Text.Replace(@"/Images/ImageFile/", @"/api/v1.0/image-file/", true, null); cog.Text = newCogText; } } await context.SaveChangesAsync(); }
public EntriesApiController( DiaryDbContext dbContext, IMapper mapper, IDiaryEntryService diaryEntryService, MainConfig config, IFileSystem fileSystem) { this._dbContext = dbContext; this._mapper = mapper; this._diaryEntryService = diaryEntryService; this._config = config; this._fileSystem = fileSystem; }
private static async Task <DiaryDbContext> CreateCurrentContext(string fileName) { var connStrMigrated = $@"Data Source={fileName};"; IConfigurationRoot configuration = new ConfigurationBuilder().Build(); var builder = new DbContextOptionsBuilder <DiaryDbContext>(); builder.UseSqlite(connStrMigrated); var context = new DiaryDbContext(builder.Options); await context.Database.MigrateAsync().ConfigureAwait(false); return(context); }
public DiaryEntryService( DiaryDbContext dbContext, IFileSystem fileSystem, MainConfig config, IStreamFactory streams, IMapper mapper) { this._dbContext = dbContext; this._fileSystem = fileSystem; this._config = config; this._streams = streams; this._mapper = mapper; }
private INoteRepository CreateNoteRepository(IComponentContext componentContext) { var connection = GetConnection(); var context = new DiaryDbContext(connection); #if DEBUG var initializer = new DiaryDbDebugInitializer(); Database.SetInitializer <DiaryDbContext>(initializer); context.Database.Initialize(false); #endif var noteRepository = new NoteRepository(context); return(noteRepository); }
public TestFixture() { this.Server = new TestServer(new WebHostBuilder() .UseStartup <TestEnvironment>()); this.Client = this.Server.CreateClient(); this.Services = this.Server.Host.Services; this.Mapper = this.Services.GetService <IMapper>(); this.DbContext = this.Services.GetService <DiaryDbContext>(); if (this.DbContext == null) { throw new NullReferenceException($"Service provider returned a null {nameof(DiaryDbContext)}."); } }
public DefaultEditionsCreator(DiaryDbContext context) { _context = context; }
public DiaryRepository(DiaryDbContext context) : base(context) { }
public LessonController(DiaryDbContext diaryDbContext) { this._diaryDbContext = diaryDbContext; }
public ScopesService(DiaryDbContext context) { _context = context ?? throw new ArgumentNullException(nameof(context)); }
public StudentController(DiaryDbContext diaryDbContext) { this._diaryDbContext = diaryDbContext; }
public TenantRoleAndUserBuilder(DiaryDbContext context, int tenantId) { _context = context; _tenantId = tenantId; }
public RecordsSearchTextService(DiaryDbContext context, IAppSettingsService appSettingsService) { _context = context ?? throw new ArgumentNullException(nameof(context)); _appSettingsService = appSettingsService ?? throw new ArgumentNullException(nameof(appSettingsService)); }
public HomeController(DiaryDbContext diaryDbContext) { _diaryDbContext = diaryDbContext; }
public HomeworkController(DiaryDbContext diaryDbContext, IWebHostEnvironment appEnvironment) { this._diaryDbContext = diaryDbContext; this._appEnvironment = appEnvironment; }
public NoteRepository(DiaryDbContext context) { _context = context; }
public ReadyHomeworkController(DiaryDbContext diaryDbContext) { this._diaryDbContext = diaryDbContext; }
public ProfileTeacherController(DiaryDbContext diaryDbContext) { this._diaryDbContext = diaryDbContext; }
public DefaultTenantCreator(DiaryDbContext context) { _context = context; }
public HostRoleAndUserCreator(DiaryDbContext context) { _context = context; }
public AuthorizationController(DiaryDbContext diaryDbContext) { this._diaryDbContext = diaryDbContext; }
public void ConfigureServices(IServiceCollection services) { _dataBaseFileName = _configuration.GetValue <string>("dbFile"); _needFileBackup = _configuration.GetValue <int>("needFileBackup") > 0; if (_needFileBackup) { SqliteFileBackup.BackupFile(_dataBaseFileName); } services.Configure <CookiePolicyOptions>(options => { options.CheckConsentNeeded = context => true; options.MinimumSameSitePolicy = SameSiteMode.None; }); services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme).AddCookie(cookieOptions => { cookieOptions.LoginPath = "/Login"; }); services.AddMvc().AddRazorPagesOptions(options => { options.Conventions.AuthorizeFolder("/"); }); services.AddDbContext <DiaryDbContext>(options => options.UseSqlite( $"Data Source={_dataBaseFileName};", o => o.UseQuerySplittingBehavior(QuerySplittingBehavior.SplitQuery))); services.AddTransient <IScopesService, ScopesService>(); services.AddTransient <IAppSettingsService, AppSettingsService>(); services.AddTransient <IRecordsThemesService, RecordsThemesService>(); services.AddTransient <IImagesService, ImagesService>(); services.AddTransient <IRecordsImagesService, RecordsImagesService>(); services.AddTransient <IImagesEditService, ImagesEditService>(); services.AddTransient <ICropImageService, CropImageService>(); services.AddTransient <IRecordsService, RecordsService>(); services.AddTransient <IRecordsSearchService, RecordsSearchService>(); services.AddTransient <IRecordsSearchTextService, RecordsSearchTextService>(); services.AddTransient <IDatesService, DatesService>(); services.AddTransient <ICalendarService, CalendarService>(); services.AddTransient <ISqliteDatabase, SqliteDatabase>(); services.AddServerSideBlazor(); int enableSwaggerUI = _configuration.GetValue <int>("enableSwaggerUI"); if (enableSwaggerUI > 0) { services.AddSwaggerDocument(); services.AddMvcCore().AddApiExplorer(); } int needMigration = _configuration.GetValue <int>("needMigration"); if (needMigration > 0) { var builder = new DbContextOptionsBuilder <DiaryDbContext>(); builder.UseSqlite($"Data Source={_dataBaseFileName};"); using var context = new DiaryDbContext(builder.Options); context.Database.Migrate(); } }
public DefaultNutritionAndDiaryBuilder(DiaryDbContext context) { _context = context; }
public SqliteDatabase(IConfiguration config, DiaryDbContext context) { _config = config; _context = context; }
public InitialHostDbBuilder(DiaryDbContext context) { _context = context; }
public GroupController(DiaryDbContext diaryDbContext) { this._diaryDbContext = diaryDbContext; }
public DefaultLanguagesCreator(DiaryDbContext context) { _context = context; }
public ImagesService(DiaryDbContext context, IAppSettingsService appSettingsService) { _context = context ?? throw new ArgumentNullException(nameof(context)); _appSettings = appSettingsService ?? throw new ArgumentNullException(nameof(appSettingsService)); }
private static async Task WriteScopesAndThemes(DiaryDbContext context, List <(string?Id, string?Name, bool Deleted)> scopes, List <(string?Id, string?ScopeId, string?ThemeName, bool Deleted, bool Actual)> themes)
public ImagesEditService(DiaryDbContext context, IAppSettingsService appSettingsService) : base(context, appSettingsService) { }