public async Task Cleanup()
        {
            CoreUnitOfWork.ClearTracker();
            Wallet wallet1 = await CoreUnitOfWork.WalletRepository.GetFirstOrDefaultWithIncludes(
                wallet => wallet.JMBG == "2904992785075",
                wallet => wallet.Transactions
                );

            if (wallet1 != null)
            {
                await CoreUnitOfWork.WalletRepository.Delete(wallet1);

                await CoreUnitOfWork.SaveChangesAsync();
            }
            Wallet wallet2 = await CoreUnitOfWork.WalletRepository.GetFirstOrDefaultWithIncludes(
                wallet => wallet.JMBG == "2904990785034",
                wallet => wallet.Transactions
                );

            if (wallet2 != null)
            {
                await CoreUnitOfWork.WalletRepository.Delete(wallet2);

                await CoreUnitOfWork.SaveChangesAsync();
            }
            await DbContext.DisposeAsync();

            DbContext = null;
        }
Example #2
0
        public async Task Cleanup()
        {
            CoreUnitOfWork.ClearTracker();
            Wallet wallet = await CoreUnitOfWork.WalletRepository.GetFirstOrDefaultWithIncludes(
                wallet => wallet.JMBG == "1203977780011",
                wallet => wallet.Transactions
                );

            if (wallet != null)
            {
                await CoreUnitOfWork.WalletRepository.Delete(wallet);

                await CoreUnitOfWork.SaveChangesAsync();
            }

            Wallet wallet2 = await CoreUnitOfWork.WalletRepository.GetFirstOrDefaultWithIncludes(
                wallet => wallet.JMBG == "1203008780011",
                wallet => wallet.Transactions
                );

            if (wallet2 != null)
            {
                await CoreUnitOfWork.WalletRepository.Delete(wallet);

                await CoreUnitOfWork.SaveChangesAsync();
            }
            await DbContext.DisposeAsync();

            DbContext = null;
        }
Example #3
0
        public async Task Setup()
        {
            var dbContextFactory = new SampleDbContextFactory();

            DbContext      = dbContextFactory.CreateDbContext(new string[] { });
            CoreUnitOfWork = new EfCoreUnitOfWork(DbContext);
            var firstBankService = new FirstBankService();

            BankRoutingService = new BankRoutingService(firstBankService);
            FeeService         = new FeeService();

            var inMemorySettings = new Dictionary <string, string> {
                { "MaxDeposit", "1000000" },
                { "MaxWithdraw", "100000" },
                { "DaysAfterWalletCreationWithNoFee", "7" },
                { "IsFirstTransferFreeInMonth", "True" },
                { "FixedFee", "100" },
                { "FeeLimit", "10000" },
                { "PercentageFee", "1" }
            };

            Configuration = new ConfigurationBuilder()
                            .AddInMemoryCollection(inMemorySettings)
                            .Build();
        }
Example #4
0
        static void Main(string[] args)
        {
            using (var context = new EfCoreDbContext())
            {
                var manageDb = new ManageDb(context);
                manageDb.AddBlog("Programing");
                manageDb.AddBlog("Cooking");
                manageDb.AddBlog("Sports");
                //manageDb.AddBlog("Knygos");

                manageDb.AddPost("C#", "All about CSharp programing", 1);
                manageDb.AddPost("dotNET", "All about dotNET programing", 1);
                manageDb.AddPost("Azure", "All about Azure", 1);
                Console.WriteLine("---------------------------------------");
                manageDb.AddPost("Chicken", "All about chicken", 2);
                manageDb.AddPost("Vegan", "Vegan food recipes", 2);
                manageDb.AddPost("AsianKitchen", "Cook perfect asian dish", 2);
                Console.WriteLine("---------------------------------------");
                manageDb.AddPost("Basketball", "Euroleague blog", 3);
                manageDb.AddPost("Football", "UEFA predictions", 3);
                manageDb.AddPost("Tennis", "Who will win Australian Open", 3);


                //////manageDb.RemovePost();

                //manageDb.GetBlogs();
                //manageDb.AddAuthor("Jonas", "Jonaitis", 1);
                //manageDb.AddAuthor("Agne", "Agnaite", 2);

                //manageDb.GetAuthors();
            }
        }
Example #5
0
        public static void Initialize(EfCoreDbContext context)
        {
            var user = new User
            {
                UserName = "******",
                RealName = "admin",
                Salt     = "123456",
                Password = ("123456".ToMd5() + "123456").ToMd5()
            };
            var role = new Role
            {
                Name        = "Admin",
                Description = "管理员"
            };
            var userRole = new UserRole
            {
                User = user,
                Role = role
            };
            var permission = new Permission
            {
                Name        = "All",
                Description = "All",
                Role        = role
            };

            context.Users.Add(user);
            context.Roles.Add(role);
            context.UserRoles.Add(userRole);
            context.Permissions.Add(permission);
            context.SaveChanges();
        }
Example #6
0
        public void SetUp()
        {
            var configuration = new ConfigurationBuilder()
                                .AddJsonFile("appsettings.json", false, false)
                                .Build();

            _db = new EfCoreDbContext(configuration);
        }
        public EfCoreQueryableTests()
        {
            _dbInitializer   = new TestDbContextInitializer();
            _dbContext       = _dbInitializer.GetTestDbContext();
            _efCoreDbContext = new EfCoreDbContext <TestDbContext>(_dbContext);

            SilverbackQueryableExtensions.Implementation = new EfCoreQueryableExtensions();
        }
Example #8
0
        private EfCoreDbContext InitContext()
        {
            var options = new DbContextOptionsBuilder <EfCoreDbContext>()
                          .UseInMemoryDatabase(databaseName: "test")
                          .Options;

            var dbContext = new EfCoreDbContext(options);

            dbContext.Database.EnsureDeleted();
            dbContext.Database.EnsureCreated();
            return(dbContext);
        }
Example #9
0
        public void SetUp()
        {
            var configuration = new ConfigurationBuilder()
                                .AddJsonFile("appsettings.json", false, false)
                                .Build();

            var conn = configuration.GetConnectionString("EfCoreDatabase");

            var optionsBuilder = new DbContextOptionsBuilder <EfCoreDbContext>()
                                 .UseSqlServer(conn, x => x
                                               .UseNetTopologySuite()
                                               .UseHierarchyId());

            _db = new EfCoreDbContext(optionsBuilder.Options);
        }
Example #10
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, EfCoreDbContext db)
        {
            if (env.IsDevelopment())
            {
                db.EnsureSeedData();
                app.UseDeveloperExceptionPage();
            }
            else
            {
                // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
                app.UseHsts();
            }

            app.UseHttpsRedirection();
            app.UseMvc();
        }
        public static List <ValidationResult> ExecuteValidation(this EfCoreDbContext context)
        {
            var result = new List <ValidationResult>();

            foreach (var entry in context.ChangeTracker.Entries().Where(t => (t.State == EntityState.Added) || (t.State == EntityState.Modified)))
            {
                var entity       = entry.Entity;
                var valProvider  = new ValidationDbContextServiceProvider(context);
                var valContext   = new ValidationContext(entity, valProvider, null);
                var entityErrors = new List <ValidationResult>();
                if (!Validator.TryValidateObject(
                        entity, valContext, entityErrors, true))
                {
                    result.AddRange(entityErrors);
                }
            }

            return(result.ToList());
        }
Example #12
0
 public EfCoreUserRepository(EfCoreDbContext dbContext) : base(dbContext)
 {
 }
Example #13
0
 public SqlServerEfCore(EfCoreDbContext context)
 {
     this._dbContext = context;
 }
Example #14
0
 public EFCoreASyncRepository(EfCoreDbContext context)
 {
     this.context = context;
 }
Example #15
0
 public EfCoreRepository(EfCoreDbContext dbContext)
 {
     _dbContext = dbContext;
 }
Example #16
0
 public BenutzerRepository(EfCoreDbContext dbContext) : base(dbContext)
 {
 }
 public Repository(IServiceProvider serviceProvider)
 {
     _context = (EfCoreDbContext)serviceProvider.GetService(typeof(EfCoreDbContext));
 }
Example #18
0
 public OrderController(EfCoreDbContext context)
 {
     _context = context;
 }
Example #19
0
 public EfCoreGroupRepository(EfCoreDbContext dbContext) : base(dbContext)
 {
 }
Example #20
0
        public EfCoreUnitOfWork(EfCoreDbContext context)
        {
            Context = context;

            WalletRepository = new WalletRepository(context);
        }
Example #21
0
 public UnitOfWork(EfCoreDbContext context)
 {
     _dbContext = context ?? throw new ArgumentNullException("ef core dbcontext can not as null");
 }
 public CustomersController(EfCoreDbContext context)
 {
     _context = context;
 }
Example #23
0
 public Repository(IUnitOfWork unit)
 {
     _dbContext = unit.DbContext;
 }
 public EFCoreProcedureRepository(EfCoreDbContext context)
 {
     this.context = context;
 }
Example #25
0
 public EfCoreDbContextTests()
 {
     _dbInitializer   = new TestDbContextInitializer();
     _dbContext       = _dbInitializer.GetTestDbContext();
     _efCoreDbContext = new EfCoreDbContext <TestDbContext>(_dbContext);
 }
Example #26
0
 public EfCoreRepository(EfCoreDbContext context)
 {
     _context = context;
     DbSet    = context.Set <TEntity>();
 }
 protected EfCoreRepositoryBase()
 {
     _dbContext = new EfCoreDbContext();
 }
Example #28
0
 protected BaseEfCoreTests(DatabaseFixture fixture)
 {
     Context = new EfCoreDbContext(fixture.Options);
 }
 public WalletRepository(EfCoreDbContext context) : base(context)
 {
 }
Example #30
0
 public ManageDb(EfCoreDbContext context)
 {
     _context = context;
     _context.Database.EnsureCreated();
 }