public void Add(DbContextBase dbCtx, object e)
 {
     if (dbCtx.Entry(e).State != EntityState.Modified)
     {
         dbCtx.Entry(e).State = EntityState.Added;
     }
 }
        public void Update(DbContextBase dbCtx, object e)
        {
            var type = e.GetType();
            if (_typesToExclude.Any(t => t.IsAssignableFrom(type)))
            {
                var pi = type.GetProperty(_propertyName);
                if (pi != null)
                {
                    dbCtx.Entry(e).OriginalValues[_propertyName] = pi.GetValue(e);
                }
            }

            _entityUpdater.Update(dbCtx, e);
        }
        public void Action(DbContextBase context)
        {
            var orders = new List<Order>
            {
                new Order
                {
                    OrderNo = SequenceNoUtils.GenerateNo('O'),
                    OrderAmount = 10000,
                    ProductNo = "PN1001",
                    UserNo = "UID1001"
                },
                new Order
                {
                    OrderNo = SequenceNoUtils.GenerateNo('O'),
                    OrderAmount = 10000,
                    ProductNo = "PN1001",
                    UserNo = "UID1001"
                },
                new Order
                {
                    OrderNo = SequenceNoUtils.GenerateNo('O'),
                    OrderAmount = 10000,
                    ProductNo = "PN1001",
                    UserNo = "UID1001"
                },
                new Order
                {
                    OrderNo = SequenceNoUtils.GenerateNo('O'),
                    OrderAmount = 10000,
                    ProductNo = "PN1001",
                    UserNo = "UID1001"
                }
            };

            orders.ForEach(context.Add);
        }
 /// <summary>
 ///
 /// </summary>
 /// <param name="dbContextBase"></param>
 /// <param name="dbContextFactory"></param>
 protected EntityFrameworkCoreFactoryRepositoryAsync(DbContextBase dbContextBase, IDbContextFactory <TDbContext> dbContextFactory) : base(dbContextBase)
 {
     _dbContextFactory = dbContextFactory;
     _contexts         = new List <TDbContext>();
 }
Exemple #5
0
 public UnitOfWork(TDbContext dbContext)
 {
     _dbContext = dbContext as DbContextBase;
 }
Exemple #6
0
 public void Setup()
 {
     _dbContext = FakeDbContext.GetInstance();
     _service   = new VictimRepository(_dbContext);
 }
 protected EfGenericRepositoryBase(DbContextBase dbContext) : base(dbContext)
 {
 }
 public RepositoryBase(DbContextBase dbContext)
 {
     DbContext = dbContext;
     DbSet     = DbContext.Set <TEntity>();
 }
Exemple #9
0
 public FormRepository(DbContextBase db)
 {
     this.db = db;
 }
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory, DbContextBase dbContextBase)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            // Details of the problem of the (Exception Handler).
            app.UseProblemDetailsExceptionHandlerConfiguration(loggerFactory);

            // Middleware that uses Serilog to log requests to Endpoints.
            app.UseSerilogRequestLogging();

            // Use initial database configurations.
            app.UseDatabaseConfiguration(env, dbContextBase);

            // Serve the static photos of registered users.
            app.UseStaticFiles(new StaticFileOptions
            {
                FileProvider      = new PhysicalFileProvider(Path.Combine(env.ContentRootPath, "StaticFiles/photos")),
                OnPrepareResponse = ctx => {
                    ctx.Context.Response.Headers.Append("Cache-Control", "public, max-age=666");
                },
                RequestPath = "/static/photos"
            });

            // Serve static files.
            app.UseFileServer(new FileServerOptions
            {
                FileProvider            = new PhysicalFileProvider(Path.Combine(env.ContentRootPath, "StaticFiles/public")),
                EnableDirectoryBrowsing = true,
                RequestPath             = "/web",
            });

            app.UseRouting();

            app.UseCors(crossOriginRequest =>
            {
                crossOriginRequest.WithMethods("OPTIONS", "GET", "POST", "PUT", "DELETE", "PATCH");
                crossOriginRequest.AllowAnyOrigin();
                crossOriginRequest.AllowAnyHeader();
                crossOriginRequest.WithExposedHeaders("x-perpro", "Cache-control", "Pragma", "x-hubin-info");
            });

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapGet("/", async context =>
                {
                    await context.Response.WriteAsync($" Hello World! Environment({env.EnvironmentName})");
                });

                endpoints.MapControllers();
            });
        }
Exemple #11
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="aggregates"></param>
 /// <param name="cancellationToken">Propagates notification that operations should be canceled.</param>
 /// <returns></returns>
 public virtual Task AddRangeAsync(IEnumerable <TAggregateRoot> aggregates, CancellationToken cancellationToken)
 {
     return(DbContextBase.SetAggregate <TAggregateRoot>().AddRangeAsync(aggregates, cancellationToken));
 }
Exemple #12
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="aggregateRoot"></param>
 /// <param name="cancellationToken">Propagates notification that operations should be canceled.</param>
 /// <returns></returns>
 public virtual Task AddAsync(TAggregateRoot aggregateRoot, CancellationToken cancellationToken)
 {
     return(DbContextBase.SetAggregate <TAggregateRoot>().AddAsync(aggregateRoot, cancellationToken).AsTask());
 }
Exemple #13
0
 public EntityRepository(DbContextBase dbContext)
 {
     this.dbContext = dbContext;
     this.DbSet     = this.dbContext.Set <TEntity>();
 }
 public EventRepository(DbContextBase dbContext) : base(dbContext)
 {
 }
 public CountryRepository(DbContextBase dbContext) : base(dbContext)
 {
 }
Exemple #16
0
 public ProjectRepository(DbContextBase context) : base(context)
 {
 }
Exemple #17
0
 public TypeBurialRepository(DbContextBase db)
 {
     this.db = db;
 }
Exemple #18
0
 public BirthPlaceRepository(DbContextBase db)
 {
     this.db = db;
 }
Exemple #19
0
 public void Setup()
 {
     _dbContext = FakeDbContext.GetInstance();
     _service   = new AttachmentBurialRepository(_dbContext);
 }
Exemple #20
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="aggregateRoot"></param>
 /// <param name="cancellationToken">Propagates notification that operations should be canceled.</param>
 /// <returns></returns>
 public Task RemoveAsync(TAggregateRoot aggregateRoot, CancellationToken cancellationToken)
 {
     DbContextBase.SetAggregate <TAggregateRoot>().Remove(aggregateRoot);
     return(TaskHelper.CompletedTask);
 }
 public Task AfterSaveChangesAsync(DbContextBase dbContextBase)
 {
     return(Task.CompletedTask);
 }
Exemple #22
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="aggregateRoot"></param>
 /// <param name="cancellationToken">Propagates notification that operations should be canceled.</param>
 /// <returns></returns>
 public virtual Task UpdateAsync(TAggregateRoot aggregateRoot, CancellationToken cancellationToken)
 {
     DbContextBase.SetAggregate <TAggregateRoot>().Update(aggregateRoot);
     return(TaskHelper.CompletedTask);
 }
 public ConscriptionPlaceRepository(DbContextBase db)
 {
     this.db = db;
 }
Exemple #24
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="aggregates"></param>
 /// <param name="cancellationToken">Propagates notification that operations should be canceled.</param>
 /// <returns></returns>
 public virtual Task UpdateRangeAsync(IEnumerable <TAggregateRoot> aggregates, CancellationToken cancellationToken)
 {
     DbContextBase.SetAggregate <TAggregateRoot>().UpdateRange(aggregates);
     return(TaskHelper.CompletedTask);
 }
 public void Setup()
 {
     _dbContext = FakeDbContext.GetInstance();
     _service   = new BirthPlaceRepository(_dbContext);
 }
Exemple #26
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="cancellationToken">Propagates notification that operations should be canceled.</param>
 /// <returns></returns>
 public virtual Task <int> RollbackAsync(CancellationToken cancellationToken)
 {
     return(DbContextBase.RollbackAsync(cancellationToken));
 }
 public RoleRepository(DbContextBase db)
 {
     this.db = db;
 }
Exemple #28
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="cancellationToken">Propagates notification that operations should be canceled.</param>
 /// <returns></returns>
 public virtual Task <int> SaveChangesAsync(CancellationToken cancellationToken)
 {
     return(DbContextBase.SaveChangesAsync(cancellationToken));
 }
 public AttachmentFormRepository(DbContextBase db)
 {
     this.db = db;
 }
Exemple #30
0
 public EfUnitOfWork(IDbContextAccessor dbContextAccessor)
 {
     _dbContext = dbContextAccessor.Context;
 }
Exemple #31
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="dbContextBase"></param>
 protected EntityFrameworkCoreRepositoryAsync(DbContextBase dbContextBase) : base(dbContextBase)
 {
 }
Exemple #32
0
 public DbContextAccessor(DbContextBase context)
 {
     Context = context;
 }
 public void Detach(DbContextBase dbCtx, object e)
 {
     dbCtx.Entry(e).State = EntityState.Detached;
 }
Exemple #34
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="cancellationToken">Propagates notification that operations should be canceled.</param>
 /// <returns></returns>
 public virtual Task <int> CountAsync(CancellationToken cancellationToken)
 {
     return(DbContextBase.SetAggregate <TAggregateRoot>().CountAsync(cancellationToken));
 }