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;
        }
Esempio n. 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;
        }
Esempio n. 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();
        }
Esempio n. 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();
            }
        }
Esempio n. 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();
        }
Esempio n. 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();
        }
Esempio n. 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);
        }
Esempio n. 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);
        }
Esempio n. 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());
        }
Esempio n. 12
0
 public EfCoreUserRepository(EfCoreDbContext dbContext) : base(dbContext)
 {
 }
Esempio n. 13
0
 public SqlServerEfCore(EfCoreDbContext context)
 {
     this._dbContext = context;
 }
Esempio n. 14
0
 public EFCoreASyncRepository(EfCoreDbContext context)
 {
     this.context = context;
 }
Esempio n. 15
0
 public EfCoreRepository(EfCoreDbContext dbContext)
 {
     _dbContext = dbContext;
 }
Esempio n. 16
0
 public BenutzerRepository(EfCoreDbContext dbContext) : base(dbContext)
 {
 }
 public Repository(IServiceProvider serviceProvider)
 {
     _context = (EfCoreDbContext)serviceProvider.GetService(typeof(EfCoreDbContext));
 }
Esempio n. 18
0
 public OrderController(EfCoreDbContext context)
 {
     _context = context;
 }
Esempio n. 19
0
 public EfCoreGroupRepository(EfCoreDbContext dbContext) : base(dbContext)
 {
 }
Esempio n. 20
0
        public EfCoreUnitOfWork(EfCoreDbContext context)
        {
            Context = context;

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