Exemple #1
0
        public static void SeedHostDb(CityInfoDbContext context)
        {
            context.SuppressAutoSetTenantId = true;

            // Host seed
            new InitialHostDbBuilder(context).Create();

            // Default tenant seed (in host database).
            new DefaultTenantBuilder(context).Create();
            new TenantRoleAndUserBuilder(context, 1).Create();
        }
Exemple #2
0
        public static void EnsureSeedDatForContext(this CityInfoDbContext context)
        {
            if (context.Cities.Any())
            {
                return;
            }
            var cities = new List <City>()
            {
                new City()
                {
                    Name            = "Iguala de la Independencia",
                    Description     = "Cuna de la Bandera Nacional",
                    PointOfInterest = new List <PointOfInterest>
                    {
                        new PointOfInterest()
                        {
                            Name        = "Asta Bandera Monumental",
                            Description = "La mas alta de LatinoAmerica"
                        },
                        new PointOfInterest()
                        {
                            Name        = "Laguna de Tuxpan",
                            Description = "Lugar de Recreacion Familiar"
                        }
                    }
                },
                new City()
                {
                    Name            = "Acapulco de Juarez",
                    Description     = "la Bahia mas hermosa del Mundo",
                    PointOfInterest = new List <PointOfInterest>()
                    {
                        new PointOfInterest()
                        {
                            Name        = "La Quebrada",
                            Description = "Lugar de emociones externas"
                        }
                    }
                }
            };

            context.Cities.AddRange(cities);
            context.SaveChanges();
        }
        public static void EnsureSeedDataForContext(this CityInfoDbContext context)
        {
            if (context.Cities.Any())
            {
                return;
            }

            var cities = new List <City>()
            {
                new City()
                {
                    Name             = "Silistra",
                    Description      = "Home Town",
                    PointsOfInterest = new List <PointOfInterest>()
                    {
                        new PointOfInterest {
                            Name = "Moskva", Description = "The Bar"
                        },
                        new PointOfInterest {
                            Name = "Krepostta", Description = "The Place"
                        }
                    }
                },
                new City()
                {
                    Name             = "Sofia",
                    Description      = "Live Town",
                    PointsOfInterest = new List <PointOfInterest>()
                    {
                        new PointOfInterest {
                            Name = "Switch", Description = "The Bar"
                        },
                        new PointOfInterest {
                            Name = "Vitosha", Description = "The Place"
                        }
                    }
                }
            };

            context.Cities.AddRange(cities);
            context.SaveChanges();
        }
Exemple #4
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app,
                              IHostingEnvironment env,
                              ILoggerFactory loggerFactory,
                              CityInfoDbContext context)
        {
            loggerFactory.AddConsole();
            loggerFactory.AddNLog();
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            context.EnsureSeedDataForContext();
            app.UseStatusCodePages();
            AutoMapper.Mapper.Initialize(map => {
                map.CreateMap <Entities.City, Models.CityWithoutpointsOfInterestDTO>();
                map.CreateMap <Entities.City, Models.CityDTO>();
                map.CreateMap <Entities.PointOfInterest, Models.PointOfInterestDTO>();
                map.CreateMap <Models.PointOfInterestCreate, Entities.PointOfInterest>();
                map.CreateMap <Models.PointOfInterestUpdate, Entities.PointOfInterest>();
                map.CreateMap <Entities.PointOfInterest, Models.PointOfInterestUpdate>();
            });
            app.UseCors(builder => builder.AllowAnyOrigin().AllowAnyMethod());

            /*app.UseCors(builder => builder.WithOrigins("http://erickpc:4200"));/*(Configuration.GetSection("Origins:Multiorigins").
             *  GetChildren().Select(s=>s.Value).Where(s=>s!=string.Empty).ToArray())
             *  .AllowAnyMethod());*/
            app.UseMvc();



            //app.Run(async (context) =>
            //{
            //    await context.Response.WriteAsync(Configuration["TestInfos:Gretings"]);
            //});
        }
 public DummyController(CityInfoDbContext context)
 {
     _context = context;
 }
Exemple #6
0
 public DefaultTenantBuilder(CityInfoDbContext context)
 {
     _context = context;
 }
Exemple #7
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="dbContext"></param>
 public CityInfoRepository(CityInfoDbContext dbContext)
 {
     _dbContext = dbContext ?? throw new ArgumentNullException(nameof(dbContext));
 }
Exemple #8
0
 public CityInfoRepository(CityInfoDbContext cityContext)
 {
     context = cityContext;
 }
Exemple #9
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, CityInfoDbContext context)
        {
            loggerFactory.AddConsole();
            loggerFactory.AddDebug();

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            context.EnsureSeedDatForContext();
            app.UseStatusCodePages();

            //Auto Mapper Configuracion
            AutoMapper.Mapper.Initialize(cfg =>
            {
                //Mapear Entidad ciudad a Dto Ciudad
                cfg.CreateMap <Entities.City, Models.CityWithoutPointOfInterestDto>();
                cfg.CreateMap <Entities.City, Models.CiudadDto>();
                cfg.CreateMap <Entities.PointOfInterest, Models.PointOfInterestDto>();
                //Crear Punto de Interes
                cfg.CreateMap <Models.PointOfInteresForCreation, Entities.PointOfInterest>();
            });

            app.UseMvc();

            //app.Run(async (context) =>
            //{

            //   // await context.Response.WriteAsync("Hello World!");
            //});
        }
Exemple #10
0
        public static void EnsureSeedDataForContext(this CityInfoDbContext context)
        {
            if (context.Cities.Any())
            {
                return;
            }
            //init seed data
            var cities = new List <City>()
            {
                new City()
                {
                    Name             = "Santo Domingo",
                    Description      = "La Capital",
                    PointsOfInterest = new List <PointOfInterest>()
                    {
                        new PointOfInterest()
                        {
                            Name        = "Zona Colonial",
                            Description = "Un lugar como de antaño"
                        },
                        new PointOfInterest()
                        {
                            Name        = "El conde",
                            Description = "La gran calle peatonal"
                        }
                    }
                },
                new City()
                {
                    Name             = "Santiago",
                    Description      = "La principal en el cibao",
                    PointsOfInterest = new List <PointOfInterest>()
                    {
                        new PointOfInterest()
                        {
                            Name        = "Centro Leon",
                            Description = "De los mejores museos del pais"
                        },
                        new PointOfInterest()
                        {
                            Name        = "El monumento de los 30 caballeros",
                            Description = "El simbolo por exelencia de la ciudad corazon"
                        }
                    }
                },
                new City()
                {
                    Name             = "La Romana",
                    Description      = "Buen polo turistico",
                    PointsOfInterest = new List <PointOfInterest>()
                    {
                        new PointOfInterest()
                        {
                            Name        = "Isla Catalina",
                            Description = "Un lugar paradisiaco con aguas cristalinas"
                        },
                        new PointOfInterest()
                        {
                            Name        = "Casa de Campo",
                            Description = "Solo para millonarios XD"
                        }
                    }
                },
                new City()
                {
                    Name             = "Higuey",
                    Description      = "La ciudad religiosa",
                    PointsOfInterest = new List <PointOfInterest>()
                    {
                        new PointOfInterest()
                        {
                            Name        = "La Basilica",
                            Description = "Iglecia catolica de gran magnitud"
                        }
                    }
                }
            };

            context.AddRange(cities);
            context.SaveChanges();
        }
 public DefaultEditionCreator(CityInfoDbContext context)
 {
     _context = context;
 }
Exemple #12
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="dbContext"></param>
 public DummyController(CityInfoDbContext dbContext)
 {
     _dbContext = dbContext ?? throw new ArgumentNullException(nameof(dbContext));
 }
Exemple #13
0
 public HostRoleAndUserCreator(CityInfoDbContext context)
 {
     _context = context;
 }
Exemple #14
0
 public TenantRoleAndUserBuilder(CityInfoDbContext context, int tenantId)
 {
     _context  = context;
     _tenantId = tenantId;
 }
Exemple #15
0
 public DefaultLanguagesCreator(CityInfoDbContext context)
 {
     _context = context;
 }
Exemple #16
0
 public InitialHostDbBuilder(CityInfoDbContext context)
 {
     _context = context;
 }
Exemple #17
0
 public CityInfoRepository(CityInfoDbContext context)
 {
     _context = context;
 }
Exemple #18
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, CityInfoDbContext context)
        {
            loggerFactory.AddConsole();
            loggerFactory.AddDebug();
            //loggerFactory.AddProvider(new NLog.Extensions.Logging.NLogLoggerProvider());
            loggerFactory.AddNLog();

            if (env.IsDevelopment())

            {
                app.UseDeveloperExceptionPage();
            }

            context.EnsureSeedDataForContext();

            //show status code instead of blank page (browser)
            app.UseStatusCodePages();
            AutoMapper.Mapper.Initialize(cnf =>
            {
                cnf.CreateMap <Entities.City, Models.CityInfoWithoutPointsOfInterest>();
                cnf.CreateMap <Entities.City, Models.CityDto>();
                cnf.CreateMap <Entities.PointOfInterest, Models.PointsOfInterestDto>();
                cnf.CreateMap <Models.PointOfInterestForCreationDto, Entities.PointOfInterest>();
                cnf.CreateMap <Models.PointOfInterestForUpdateDto, Entities.PointOfInterest>();
                cnf.CreateMap <Entities.PointOfInterest, Models.PointOfInterestForUpdateDto>();
            });
            app.UseMvc();

            //app.Run(async (context) =>
            //{
            //    await context.Response.WriteAsync("Hello World!");
            //});
        }
Exemple #19
0
 public DefaultSettingsCreator(CityInfoDbContext context)
 {
     _context = context;
 }
 public DummyController(CityInfoDbContext ctx)
 {
     _ctx = ctx;
 }