public CountryGridVM GetCountries(DataTableModel table)
        {
            CountryGridVM result = new CountryGridVM();

            using (CountryDbContext context = new CountryDbContext())
            {
                //5. büyük nüfusa sahip ülke alınıyor
                IQueryable <Country> countryQuery = context.CountryList.Include("Region");

                if (!string.IsNullOrEmpty(table.sSearch))
                {
                    string searchText = table.sSearch.ToLower();
                    countryQuery = countryQuery.Where(c => c.CapitalCity.Contains(searchText) || c.Name.Contains(searchText) ||
                                                      c.FullName.Contains(searchText) || c.Code.Contains(searchText) || c.Region.Name.Contains(searchText));
                }
                result.TotalCount = countryQuery.Count();
                if (!string.IsNullOrEmpty(table.SingleSortingColumn))
                {
                    countryQuery = countryQuery.OrderByField(table.SingleSortingColumn, table.SingleSortDirection);
                }
                else
                {
                    countryQuery = countryQuery.OrderByDescending(m => m.Population);
                }

                countryQuery = countryQuery.Skip(table.iDisplayStart).Take(table.iDisplayLength);

                result.CountryList = countryQuery.ToList();
                if (AppConfig.RenderFlagOnGrid)
                {
                    result.CountryList.ForEach(c => c.Base64FlagData = Convert.ToBase64String(File.ReadAllBytes(AppConfig.FlagPath + string.Format(c.Flag, AppConfig.FlagResolution))));
                }
            }
            return(result);
        }
 public long GetMinYellowPopulation()
 {
     using (CountryDbContext context = new CountryDbContext())
     {
         return(context.CountryList.OrderByDescending(c => c.Population).Skip(AppConfig.YellowLineCount - 1).Take(1).Select(c => c.Population).FirstOrDefault());
     }
 }
Exemple #3
0
        public CountryObjectsRepositoryTests()
        {
            var options = new DbContextOptionsBuilder <CountryDbContext>().UseInMemoryDatabase("TestDb").Options;

            db         = new CountryDbContext(options);
            repository = new CountryObjectsRepository(db);
        }
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, CountryDbContext context)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
                // 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.UseStaticFiles();
            app.UseCookiePolicy();

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");
            });
            SeedDatabase.SeedDb(context);
        }
        public string GetFlagName(int id)
        {
            string flagName = null;

            using (CountryDbContext context = new CountryDbContext())
            {
                flagName = context.CountryList.Where(c => c.Id == id).Select(c => c.Flag).FirstOrDefault();
            }
            return(flagName);
        }
Exemple #6
0
        static void Main(string[] args)
        {
            //var optionsBuilder = new DbContextOptionsBuilder<CountryDbContext>();
            //optionsBuilder.UseSqlite(@"Data Source=C:\Users\omakhin\RiderProjects\BorderCrossing\BorderCrossing.Console\BorderCrossing.db", b => {
            //    b.UseNetTopologySuite();
            //});

            string connectionString = "Server=localhost;Database=BorderCrossing;Trusted_Connection=True;";

            var optionsBuilder2 = new DbContextOptionsBuilder <CountryDbContext>();

            optionsBuilder2.UseSqlServer(connectionString, b =>
            {
                b.UseNetTopologySuite();
            });

            //var dbl = new CountryDbContext(optionsBuilder.Options);
            var dbs = new CountryDbContext(optionsBuilder2.Options);

            List <Country> countries = new List <Country>();

            GeoJsonWriter writer = new GeoJsonWriter();

            foreach (var country in dbs.Countries)
            {
                var c = new Country()
                {
                    Name   = country.Name,
                    Region = country.Region,
                    Geom   = writer.Write(country.Geom)
                };

                countries.Add(c);
                //dbl.Countries.Add(c);
                //dbl.SaveChanges();
            }

            var json = JSON.Serialize(countries);

            File.WriteAllText(@"c:\temp\c3.json", json);
        }
Exemple #7
0
        public CityValidation(CountryDbContext Dbcontext)

        {
            _Dbcontext = Dbcontext;
        }
Exemple #8
0
 public CountryRepository(CountryDbContext context)
 {
     _context = context;
 }
Exemple #9
0
 public HomeController(CountryDbContext coContext, CurrencyDbContext cuContext)
 {
     countryContext  = coContext;
     currencyContext = cuContext;
 }
 public void Dispose()
 {
     Context.Dispose();
     Context = null;
 }
 public BaseOperation(CountryDbContext context)
 {
     this.Context = context;
     this.DbSet   = context.Set <TEntity>();
 }
Exemple #12
0
        public StateValidation(CountryDbContext Dbcontext)

        {
            _Dbcontext = Dbcontext;
        }
Exemple #13
0
 public CityServices(CountryDbContext dbContext, IMapper mapper)
 {
     _dbContext = dbContext;
     _mapper    = mapper;
 }
Exemple #14
0
        public ValidateCountry(CountryDbContext Dbcontext)

        {
            _Dbcontext = Dbcontext;
        }
Exemple #15
0
 public CountryRepository() : base(new CountryDbContext())
 {
     _db = Context as CountryDbContext;
 }