Exemplo n.º 1
0
        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();
        }
Exemplo n.º 2
0
 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;
 }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
 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;
 }
Exemplo n.º 5
0
        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);
        }
Exemplo n.º 6
0
        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;
 }
Exemplo n.º 8
0
 public DiaryRepository(DiaryDbContext context) : base(context)
 {
 }
Exemplo n.º 9
0
 public LessonController(DiaryDbContext diaryDbContext)
 {
     this._diaryDbContext = diaryDbContext;
 }
Exemplo n.º 10
0
 public ScopesService(DiaryDbContext context)
 {
     _context = context ?? throw new ArgumentNullException(nameof(context));
 }
Exemplo n.º 11
0
 public StudentController(DiaryDbContext diaryDbContext)
 {
     this._diaryDbContext = diaryDbContext;
 }
Exemplo n.º 12
0
 public TenantRoleAndUserBuilder(DiaryDbContext context, int tenantId)
 {
     _context  = context;
     _tenantId = tenantId;
 }
Exemplo n.º 13
0
 public RecordsSearchTextService(DiaryDbContext context, IAppSettingsService appSettingsService)
 {
     _context            = context ?? throw new ArgumentNullException(nameof(context));
     _appSettingsService = appSettingsService ?? throw new ArgumentNullException(nameof(appSettingsService));
 }
Exemplo n.º 14
0
 public HomeController(DiaryDbContext diaryDbContext)
 {
     _diaryDbContext = diaryDbContext;
 }
Exemplo n.º 15
0
 public HomeworkController(DiaryDbContext diaryDbContext, IWebHostEnvironment appEnvironment)
 {
     this._diaryDbContext = diaryDbContext;
     this._appEnvironment = appEnvironment;
 }
Exemplo n.º 16
0
 public NoteRepository(DiaryDbContext context)
 {
     _context = context;
 }
Exemplo n.º 17
0
 public ReadyHomeworkController(DiaryDbContext diaryDbContext)
 {
     this._diaryDbContext = diaryDbContext;
 }
Exemplo n.º 18
0
 public ProfileTeacherController(DiaryDbContext diaryDbContext)
 {
     this._diaryDbContext = diaryDbContext;
 }
Exemplo n.º 19
0
 public DefaultTenantCreator(DiaryDbContext context)
 {
     _context = context;
 }
Exemplo n.º 20
0
 public HostRoleAndUserCreator(DiaryDbContext context)
 {
     _context = context;
 }
Exemplo n.º 21
0
 public AuthorizationController(DiaryDbContext diaryDbContext)
 {
     this._diaryDbContext = diaryDbContext;
 }
Exemplo n.º 22
0
        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;
 }
Exemplo n.º 24
0
 public SqliteDatabase(IConfiguration config, DiaryDbContext context)
 {
     _config  = config;
     _context = context;
 }
Exemplo n.º 25
0
 public InitialHostDbBuilder(DiaryDbContext context)
 {
     _context = context;
 }
Exemplo n.º 26
0
 public GroupController(DiaryDbContext diaryDbContext)
 {
     this._diaryDbContext = diaryDbContext;
 }
Exemplo n.º 27
0
 public DefaultLanguagesCreator(DiaryDbContext context)
 {
     _context = context;
 }
Exemplo n.º 28
0
 public ImagesService(DiaryDbContext context, IAppSettingsService appSettingsService)
 {
     _context     = context ?? throw new ArgumentNullException(nameof(context));
     _appSettings = appSettingsService ?? throw new ArgumentNullException(nameof(appSettingsService));
 }
Exemplo n.º 29
0
 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)
Exemplo n.º 30
0
 public ImagesEditService(DiaryDbContext context, IAppSettingsService appSettingsService) : base(context, appSettingsService)
 {
 }