Beispiel #1
0
 public UnitOfWork(IResolveManager resolveManager, PtvDbContext dbContext)
 {
     this.resolveManager = resolveManager;
     this.DbContext      = dbContext;
     Configure();
     CustomConfigure();
 }
Beispiel #2
0
        /// <summary>
        /// Default constructor for base repository.
        /// </summary>
        /// <exception cref="ArgumentNullException">When context is null.</exception>
        /// <param name="context">Data context for repository instance.</param>
        public Repository(PtvDbContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context", "Argument 'context' can not be null!");
            }

            DataContext = context;
        }
Beispiel #3
0
 private void CloseContext(PtvDbContext context)
 {
     if (context == null)
     {
         return;
     }
     try { context.Database.CloseConnection(); } catch { }
     try { context.Dispose(); } catch {}
 }
Beispiel #4
0
 public UnitOfWorkWritable(IResolveManager resolveManager, PtvDbContext dbContext, IUserIdentification userIdentification, ILogger <UnitOfWorkWritable> logger, ApplicationConfiguration applicationConfiguration, ILockingManager lockingManager, IRoleChecker roleChecker, ITranslationCloneCache translationCloneCache) : base(resolveManager, dbContext)
 {
     this.userIdentification       = userIdentification;
     this.logger                   = logger;
     this.applicationConfiguration = applicationConfiguration;
     this.lockingManager           = lockingManager;
     this.roleChecker              = roleChecker;
     this.translationCloneCache    = translationCloneCache;
 }
Beispiel #5
0
 /// <summary>
 /// Applies all database migrations.
 /// </summary>
 /// <param name="serviceProvider">Microsoft.AspNetCore.Builder.IServiceProvider</param>
 /// <remarks>You should call this method from Application Startup.Configure method. Call this method before you call the seeding methods.</remarks>
 /// <exception cref="System.ArgumentNullException"><i>app</i> is a null reference</exception>
 public static void DoMigration(IServiceProvider serviceProvider)
 {
     if (serviceProvider == null)
     {
         throw new ArgumentNullException(nameof(serviceProvider));
     }
     CoreExtensions.RunInThreadAndWait(() =>
     {
         // do EF migrations in own scope - see https://github.com/aspnet/EntityFramework/issues/3070
         using (var serviceScope = serviceProvider.GetRequiredService <IServiceScopeFactory>().CreateScope())
         {
             PtvDbContext dbContext = serviceScope.ServiceProvider.GetService <PtvDbContext>();
             // run migrations automatically
             dbContext.Database.Migrate();
             var seedingService = serviceScope.ServiceProvider.GetService <ISeedingService>();
             seedingService.SeedTypes();
         }
     });
 }
Beispiel #6
0
 public HealthCheckResult VerifyDatabaseConnection()
 {
     using (var serviceScope = serviceProvider.GetRequiredService <IServiceScopeFactory>().CreateScope())
     {
         PtvDbContext          dbContext   = serviceScope.ServiceProvider.GetService <PtvDbContext>();
         IDbContextTransaction transaction = null;
         try
         {
             dbContext.Database.OpenConnection();
             transaction = dbContext.Database.BeginTransaction(TesterIsolationLevel);
             dbContext.Languages.Any();
             return(HealthCheckResult.Ok);
         }
         catch (Exception) { }
         finally
         {
             RollBackTransaction(transaction);
             CloseContext(dbContext);
         }
     }
     return(HealthCheckResult.Failed);
 }
Beispiel #7
0
 /// <summary>
 /// Default constructor for base repository.
 /// </summary>
 /// <exception cref="ArgumentNullException">When context is null.</exception>
 /// <param name="context">Data context for repository instance.</param>
 /// <param name="prefilteringManager">Prefiltering manager for query filters.</param>
 public ServiceClassDescriptionRepository(PtvDbContext context, IPrefilteringManager prefilteringManager)
     : base(context, prefilteringManager)
 {
 }
Beispiel #8
0
 /// <summary>
 /// Default constructor for base repository.
 /// </summary>
 /// <exception cref="ArgumentNullException">When context is null.</exception>
 /// <param name="context">Data context for repository instance.</param>
 /// <param name="prefilteringManager">Prefiltering manager for query filters.</param>
 public ServiceChannelTypeRepository(PtvDbContext context, IPrefilteringManager prefilteringManager)
     : base(context, prefilteringManager)
 {
 }
 /// <summary>
 /// Default constructor for base repository.
 /// </summary>
 /// <exception cref="ArgumentNullException">When context is null.</exception>
 /// <param name="context">Data context for repository instance.</param>
 /// <param name="prefilteringManager">Prefiltering manager for query filters.</param>
 public GeneralDescriptionServiceChannelDescriptionRepository(PtvDbContext context, IPrefilteringManager prefilteringManager)
     : base(context, prefilteringManager)
 {
 }
Beispiel #10
0
 /// <summary>
 /// Default constructor for base repository.
 /// </summary>
 /// <exception cref="ArgumentNullException">When context is null.</exception>
 /// <param name="context">Data context for repository instance.</param>
 /// <param name="prefilteringManager">Prefiltering manager for query filters.</param>
 public ExceptionHoursStatusTypeRepository(PtvDbContext context, IPrefilteringManager prefilteringManager)
     : base(context, prefilteringManager)
 {
 }
Beispiel #11
0
 /// <summary>
 /// Default constructor for base repository.
 /// </summary>
 /// <exception cref="ArgumentNullException">When context is null.</exception>
 /// <param name="context">Data context for repository instance.</param>
 /// <param name="prefilteringManager">Prefiltering manager for query filters.</param>
 public ServiceCollectionVersionedRepository(PtvDbContext context, IPrefilteringManager prefilteringManager)
     : base(context, prefilteringManager)
 {
 }
Beispiel #12
0
 /// <summary>
 /// Default constructor for base repository.
 /// </summary>
 /// <exception cref="ArgumentNullException">When context is null.</exception>
 /// <param name="context">Data context for repository instance.</param>
 /// <param name="prefilteringManager">Prefiltering manager for query filters.</param>
 public WebPageTypeNameRepository(PtvDbContext context, IPrefilteringManager prefilteringManager)
     : base(context, prefilteringManager)
 {
 }
Beispiel #13
0
 /// <summary>
 /// Default constructor for base repository.
 /// </summary>
 /// <exception cref="ArgumentNullException">When context is null.</exception>
 /// <param name="context">Data context for repository instance.</param>
 /// <param name="prefilteringManager">Prefiltering manager for query filters.</param>
 public IndustrialClassNameRepository(PtvDbContext context, IPrefilteringManager prefilteringManager)
     : base(context, prefilteringManager)
 {
 }
 /// <summary>
 /// Default constructor for base repository.
 /// </summary>
 /// <exception cref="ArgumentNullException">When context is null.</exception>
 /// <param name="context">Data context for repository instance.</param>
 /// <param name="prefilteringManager">Prefiltering manager for query filters.</param>
 public OrganizationTypeRepository(PtvDbContext context, IPrefilteringManager prefilteringManager)
     : base(context, prefilteringManager)
 {
 }
Beispiel #15
0
 /// <summary>
 /// Default constructor for base repository.
 /// </summary>
 /// <exception cref="ArgumentNullException">When context is null.</exception>
 /// <param name="context">Data context for repository instance.</param>
 /// <param name="prefilteringManager">Prefiltering manager for query filters.</param>
 public AddressCharacterRepository(PtvDbContext context, IPrefilteringManager prefilteringManager)
     : base(context, prefilteringManager)
 {
 }
 /// <summary>
 /// Default constructor for base repository.
 /// </summary>
 /// <exception cref="ArgumentNullException">When context is null.</exception>
 /// <param name="context">Data context for repository instance.</param>
 /// <param name="prefilteringManager">Prefiltering manager for query filters.</param>
 public OrganizationBlockedAccessRightRepository(PtvDbContext context, IPrefilteringManager prefilteringManager)
     : base(context, prefilteringManager)
 {
 }
Beispiel #17
0
 /// <summary>
 /// Default constructor for base repository.
 /// </summary>
 /// <exception cref="ArgumentNullException">When context is null.</exception>
 /// <param name="context">Data context for repository instance.</param>
 /// <param name="prefilteringManager">Prefiltering manager for query filters.</param>
 public TargetGroupNameRepository(PtvDbContext context, IPrefilteringManager prefilteringManager)
     : base(context, prefilteringManager)
 {
 }
Beispiel #18
0
 /// <summary>
 /// Default constructor for base repository.
 /// </summary>
 /// <exception cref="ArgumentNullException">When context is null.</exception>
 /// <param name="context">Data context for repository instance.</param>
 /// <param name="prefilteringManager">Prefiltering manager for query filters.</param>
 public ElectronicChannelUrlRepository(PtvDbContext context, IPrefilteringManager prefilteringManager)
     : base(context, prefilteringManager)
 {
 }
 /// <summary>
 /// Default constructor for base repository.
 /// </summary>
 /// <exception cref="ArgumentNullException">When context is null.</exception>
 /// <param name="context">Data context for repository instance.</param>
 /// <param name="prefilteringManager">Prefiltering manager for query filters.</param>
 public ExtraSubTypeRepository(PtvDbContext context, IPrefilteringManager prefilteringManager)
     : base(context, prefilteringManager)
 {
 }
 /// <summary>
 /// Default constructor for base repository.
 /// </summary>
 /// <exception cref="ArgumentNullException">When context is null.</exception>
 /// <param name="context">Data context for repository instance.</param>
 /// <param name="prefilteringManager">Prefiltering manager for query filters.</param>
 public AddressForeignTextNameRepository(PtvDbContext context, IPrefilteringManager prefilteringManager)
     : base(context, prefilteringManager)
 {
 }
Beispiel #21
0
 /// <summary>
 /// Default constructor for base repository.
 /// </summary>
 /// <exception cref="ArgumentNullException">When context is null.</exception>
 /// <param name="context">Data context for repository instance.</param>
 /// <param name="prefilteringManager">Prefiltering manager for query filters.</param>
 public ServiceHoursAdditionalInformationRepository(PtvDbContext context, IPrefilteringManager prefilteringManager)
     : base(context, prefilteringManager)
 {
 }
 /// <summary>
 /// Default constructor for base repository.
 /// </summary>
 /// <exception cref="ArgumentNullException">When context is null.</exception>
 /// <param name="context">Data context for repository instance.</param>
 /// <param name="prefilteringManager">Prefiltering manager for query filters.</param>
 public ServiceLanguageRepository(PtvDbContext context, IPrefilteringManager prefilteringManager)
     : base(context, prefilteringManager)
 {
 }
Beispiel #23
0
 /// <summary>
 /// Default constructor for base repository.
 /// </summary>
 /// <exception cref="ArgumentNullException">When context is null.</exception>
 /// <param name="context">Data context for repository instance.</param>
 /// <param name="prefilteringManager">Prefiltering manager for query filters.</param>
 public AreaRepository(PtvDbContext context, IPrefilteringManager prefilteringManager)
     : base(context, prefilteringManager)
 {
 }
Beispiel #24
0
 /// <summary>
 /// Default constructor for base repository.
 /// </summary>
 /// <exception cref="ArgumentNullException">When context is null.</exception>
 /// <param name="context">Data context for repository instance.</param>
 /// <param name="prefilteringManager">Prefiltering manager for query filters.</param>
 public AddressPostOfficeBoxRepository(PtvDbContext context, IPrefilteringManager prefilteringManager)
     : base(context, prefilteringManager)
 {
 }
 /// <summary>
 /// Default constructor for base repository.
 /// </summary>
 /// <exception cref="ArgumentNullException">When context is null.</exception>
 /// <param name="context">Data context for repository instance.</param>
 /// <param name="prefilteringManager">Prefiltering manager for query filters.</param>
 public ServiceProducerOrganizationRepository(PtvDbContext context, IPrefilteringManager prefilteringManager)
     : base(context, prefilteringManager)
 {
 }
Beispiel #26
0
 /// <summary>
 /// Default constructor for base repository.
 /// </summary>
 /// <exception cref="ArgumentNullException">When context is null.</exception>
 /// <param name="context">Data context for repository instance.</param>
 /// <param name="prefilteringManager">Prefiltering manager for query filters.</param>
 public ProvisionTypeNameRepository(PtvDbContext context, IPrefilteringManager prefilteringManager)
     : base(context, prefilteringManager)
 {
 }
Beispiel #27
0
 /// <summary>
 /// Default constructor for base repository.
 /// </summary>
 /// <exception cref="ArgumentNullException">When context is null.</exception>
 /// <param name="context">Data context for repository instance.</param>
 /// <param name="prefilteringManager">Prefiltering manager for query filters.</param>
 public ServiceChannelLanguageAvailabilityRepository(PtvDbContext context, IPrefilteringManager prefilteringManager)
     : base(context, prefilteringManager)
 {
 }
 /// <summary>
 /// Default constructor for base repository.
 /// </summary>
 /// <exception cref="ArgumentNullException">When context is null.</exception>
 /// <param name="context">Data context for repository instance.</param>
 /// <param name="prefilteringManager">Prefiltering manager for query filters.</param>
 public StatutoryServiceIndustrialClassRepository(PtvDbContext context, IPrefilteringManager prefilteringManager)
     : base(context, prefilteringManager)
 {
 }
 /// <summary>
 /// Default constructor for base repository.
 /// </summary>
 /// <exception cref="ArgumentNullException">When context is null.</exception>
 /// <param name="context">Data context for repository instance.</param>
 /// <param name="prefilteringManager">Prefiltering manager for query filters.</param>
 public CountryNameRepository(PtvDbContext context, IPrefilteringManager prefilteringManager)
     : base(context, prefilteringManager)
 {
 }
 /// <summary>
 /// Default constructor for base repository.
 /// </summary>
 /// <exception cref="ArgumentNullException">When context is null.</exception>
 /// <param name="context">Data context for repository instance.</param>
 /// <param name="prefilteringManager">Prefiltering manager for query filters.</param>
 public GeneralDescriptionBlockedAccessRightRepository(PtvDbContext context, IPrefilteringManager prefilteringManager)
     : base(context, prefilteringManager)
 {
 }