Exemplo n.º 1
0
 public DummyController(TempleInfoContext ctx)
 {
     _ctx = ctx;
 }
Exemplo n.º 2
0
 public TempleInfoRepository(TempleInfoContext ctx)
 {
     _ctx = ctx;
 }
Exemplo n.º 3
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, TempleInfoContext templeInfoContext)
        {
            loggerFactory.AddConsole();

            loggerFactory.AddDebug();


            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler();
            }

            templeInfoContext.EnsureSeedDataForContext();

            //used for responses that don't hahve a body
            app.UseStatusCodePages();

            app.UseMvc();

            AutoMapper.Mapper.Initialize(cfg =>
            {
                cfg.CreateMap <Entities.Temple, Models.TempleOnlyDTO>();
                cfg.CreateMap <Entities.Temple, Models.TempleDTO>();
                cfg.CreateMap <Entities.PointOfInterest, Models.PointOfInterestDto>();
                cfg.CreateMap <Models.PointOfInterestCreationDto, Entities.PointOfInterest>();
                cfg.CreateMap <Models.PointOfInterestUpdateDto, Entities.PointOfInterest>();
                cfg.CreateMap <Models.PointOfInterestDto, Entities.PointOfInterest>();
            });

            //app.Run(async (context) =>
            //{
            //    throw new Exception("Example exception");
            //});


            //app.Run(async (context) =>
            //{
            //    await context.Response.WriteAsync("Hello World!");
            //});
        }
Exemplo n.º 4
0
        public static void EnsureSeedDataForContext(this TempleInfoContext context)
        {
            if (context.Temples.Any())
            {
                return;
            }

            var temples = new List <Temple>()
            {
                new Temple()
                {
                    Name             = "Salt Lake City temple",
                    Description      = "The one with big spires.",
                    PointsOfInterest = new List <PointOfInterest>()
                    {
                        new PointOfInterest()
                        {
                            Name        = "Salt Lake",
                            Description = "As stated, a very salty lake."
                        },
                        new PointOfInterest()
                        {
                            Name        = "Visitor Center",
                            Description = "Missionaries from all around the world serve here. "
                        },
                    }
                },
                new Temple()
                {
                    Name             = "Washington D.C.",
                    Description      = "Very dramatic temple with with views along the highway.",
                    PointsOfInterest = new List <PointOfInterest>()
                    {
                        new PointOfInterest()
                        {
                            Name        = "Parking is easy to find",
                            Description = "First major temple east of the Mississipi."
                        },
                        new PointOfInterest()
                        {
                            Name        = "Temple Gardens",
                            Description = "The the finest example of flowers"
                        },
                    }
                },
                new Temple()
                {
                    Name             = "Paris",
                    Description      = "Temple in France.",
                    PointsOfInterest = new List <PointOfInterest>()
                    {
                        new PointOfInterest()
                        {
                            Name        = "Eiffel Tower",
                            Description = "A wrought iron lattice tower on the Champ de Mars, named after engineer Gustave Eiffel."
                        },
                        new PointOfInterest()
                        {
                            Name        = "The Louvre",
                            Description = "The world's largest museum."
                        },
                    }
                }
            };

            context.Temples.AddRange(temples);
            context.SaveChanges();
        }