Ejemplo n.º 1
0
        public static void EnsureSeedDataForContext(this SignSystemInfoContext context)
        {
            Sign sign1 = new Sign()
            {
                Model  = "64x64",
                Width  = 64,
                Height = 64
            };
            Sign sign2 = new Sign()
            {
                Model  = "320x96",
                Width  = 320,
                Height = 96
            };

            if (!context.Sign.Any())
            {
                var signs = new List <Sign>()
                {
                    sign1,
                    sign2
                };
                context.Sign.AddRange(signs);
                context.SaveChanges();
            }
            if (!context.Store.Any())
            {
                var stores = new List <Store>()
                {
                    new Store
                    {
                        Name      = "Kangaroo Point",
                        Manager   = "brian",
                        IpAddress = "192.168.0.1",
                        SubMask   = "255.255.255.255",
                        Port      = "5200",
                        SignId    = 1
                    },
                    new Store()
                    {
                        Name      = "Cairns",
                        Manager   = "Jodie",
                        IpAddress = "192.168.0.12",
                        SubMask   = "255.255.255.255",
                        Port      = "5200",
                        SignId    = 2
                    }
                };
                context.Store.AddRange(stores);
                context.SaveChanges();
            }
        }
Ejemplo n.º 2
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,
                              SignSystemInfoContext signSystemInfoContext)
        {
            loggerFactory.AddConsole();

            loggerFactory.AddDebug();

            //loggerFactory.AddProvider(new NLog.Extensions.Logging.NLogLoggerProvider());
            loggerFactory.AddNLog();

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

            //   signSystemInfoContext.EnsureSeedDataForContext();

            app.UseStatusCodePages();

            AutoMapper.Mapper.Initialize(cfg =>
            {
                //cfg.CreateMap<Entities.City, SignDto>();
                //cfg.CreateMap<Entities.City, Models.CityDto>();
                //cfg.CreateMap<Entities.PointOfInterest, Models.PointOfInterestDto>();
                //cfg.CreateMap<Models.PointOfInterestForCreationDto, Entities.PointOfInterest>();
                //cfg.CreateMap<Models.PointOfInterestForUpdateDto, Entities.PointOfInterest>();
                //cfg.CreateMap<Entities.PointOfInterest, Models.PointOfInterestForUpdateDto>();
                cfg.CreateMap <Entities.Sign, SignDto>();
                cfg.CreateMap <Entities.Store, Models.Stores.StoreDto>();
            });

            app.UseMvc();

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

            //app.Run(async (context) =>
            //{
            //    await context.Response.WriteAsync("Hello World!");
            //});
        }
Ejemplo n.º 3
0
 public SignRepository(SignSystemInfoContext context)
 {
     _context = context;
 }
Ejemplo n.º 4
0
 public DummyController(SignSystemInfoContext ctx)
 {
     _ctx = ctx;
 }