public RepositoryWrapper(CityInfoContext repositoryContext) { this._repoContext = repositoryContext; }
// 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, CityInfoContext cityInfoContext) { loggerFactory.AddConsole(); loggerFactory.AddDebug(); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } //cityInfoContext.EnsureSeedDataForContext(); app.UseStatusCodePages(); //Return 200's, 300's, etc. //app.UseAuthentication(); //Comment to disable authorization app.UseMvc(); AutoMapper.Mapper.Initialize(cfg => { cfg.CreateMap <Entities.City, Models.CityWithoutPointsOfInterestDTO>(); cfg.CreateMap <Entities.City, Models.CityDTO>(); cfg.CreateMap <Entities.PointOfInterest, Models.PointOfInterestDTO>(); cfg.CreateMap <Models.PointOfInterestForCreationDTO, Entities.PointOfInterest>(); cfg.CreateMap <Models.PointOfInterestForUpdateDTO, PointOfInterest>(); cfg.CreateMap <PointOfInterest, Models.PointOfInterestForUpdateDTO>(); }); // Enable middleware to serve generated Swagger as a JSON endpoint. app.UseSwagger(); // Enable middleware to serve swagger-ui (HTML, JS, CSS, etc.), // specifying the Swagger JSON endpoint. app.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", "Hillman API V1"); c.RoutePrefix = string.Empty; }); }
public CityInfoRepository(CityInfoContext context) { _context = context ?? throw new ArgumentNullException(nameof(context)); }
public MayorRepository(CityInfoContext context) { _context = context; }
// 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, CityInfoContext cityInfoContext) { loggerFactory.AddConsole(); loggerFactory.AddDebug(); //loggerFactory.AddProvider(new NLog.Extensions.Logging.NLogLoggerProvider()); loggerFactory.AddNLog(); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseHsts(); } cityInfoContext.EnsureSeedDataForContext(); app.UseStatusCodePages(); app.UseHttpsRedirection(); AutoMapper.Mapper.Initialize(cfg => { cfg.CreateMap <City, CityWithoutPointsOfInterestDto>(); cfg.CreateMap <City, CityDto>(); cfg.CreateMap <PointOfInterest, PointOfInterestDto>(); cfg.CreateMap <PointOfInterestCreationDto, PointOfInterest>(); cfg.CreateMap <PointOfInterestForUpdateDto, PointOfInterest>(); cfg.CreateMap <PointOfInterest, PointOfInterestForUpdateDto>(); }); app.UseMvc(); }
// 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, CityInfoContext cityInfoContext) { loggerFactory.AddConsole(); loggerFactory.AddDebug(LogLevel.Information); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler(appBuilder => { appBuilder.Run(async context => { context.Response.StatusCode = 500; await context.Response.WriteAsync("An unexpected fault happened. Try again later."); }); }); } AutoMapper.Mapper.Initialize(cfg => { cfg.CreateMap <City, CityDto>(); cfg.CreateMap <Spot, SpotDto>() .ForMember(dest => dest.PreviewImage, opt => opt.MapFrom(src => "http://localhost:35437/images/" + src.PreviewImage)) .ForMember(dest => dest.Type, opt => opt.MapFrom(src => src.Type.Name)); }); //cityInfoContext.EnsureSeedDataForContext(); app.UseMvc(); app.UseStaticFiles(); //This line enables the app to use Swagger, with the configuration in the ConfigureServices method. app.UseSwagger(); //This line enables Swagger UI, which provides us with a nice, simple UI with which we can view our API calls. app.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", "Swagger JalanJalan"); }); }
public DummyController(CityInfoContext context) { _context = context; }
public PointsOfInterest(ILogger <PointsOfInterest> logger, IMailService mailService , ICityInfoRepository infoRepository, IMapper mapper, CityInfoContext cityInfoContext) { this.logger = logger ?? throw new ArgumentNullException(nameof(logger)); this._mailService = mailService ?? throw new ArgumentNullException(nameof(mailService)); this.infoRepository = infoRepository; this.mapper = mapper; this.cityInfoContext = cityInfoContext; }
// 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, CityInfoContext cityInfoContext) { loggerFactory.AddNLog(); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler(); } cityInfoContext.EnsureSeedDataForContext(); app.UseStatusCodePages(); AutoMapper.Mapper.Initialize(cfg => { cfg.CreateMap <Entities.City, Models.CityWithoutPointsOfInterestDto>(); cfg.CreateMap <Entities.City, Models.CityDto>(); cfg.CreateMap <Entities.PointOfInterest, Models.PointOfInterestDto>(); }); app.UseMvc(); }
public static void EnsureSeedDataForContext(this CityInfoContext context) { if (context.Cities.Any()) { return; } var cities = new List <City>() { new City() { Name = "Fortaleza", Description = "Fortaleza é um município brasileiro, situado na região Nordeste do país.", PointsOfInterest = new List <PointOfInterest>() { new PointOfInterest() { Name = "Praia do Iracema", Description = "Uma praia de bairro homônimo localizados no município de Fortaleza." }, new PointOfInterest() { Name = "Beack Park", Description = "É um complexo turístico do litoral do Nordeste do Brasil." } } }, new City() { Name = "Rio de Janeiro", Description = "Rio de Janeiro é um município brasileiro, situado na região Sudeste do país.", PointsOfInterest = new List <PointOfInterest>() { new PointOfInterest() { Name = "Praia Copacabana", Description = "É considerado um dos bairros mais conhecidos do mundo." }, new PointOfInterest() { Name = "Cristo Redentor", Description = "Em 2007 foi eleito informalmente como uma das sete maravilhas do mundo moderno." } } }, new City() { Name = "Caucaia", Description = "Caucaia é um município limítrofes brasileiro, situado na região Nordeste do país.", PointsOfInterest = new List <PointOfInterest>() { new PointOfInterest() { Name = "Praia do Cumbuco", Description = "Não é lá essas coisas mais da pra curti." }, new PointOfInterest() { Name = "Parque Botânico do Ceará", Description = "possui uma área de 190 hectares, bom lugar para apreciar a natureza." } } } }; context.Cities.AddRange(cities); context.SaveChanges(); }
// 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, CityInfoContext cityInfoContext) { AutoMapper.Mapper.Initialize(Cfg => { Cfg.CreateMap <Entities.City, Models.CityWithoutPointOfInterestDto>(); 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>(); }); // Env variables // https://docs.microsoft.com/en-us/aspnet/core/fundamentals/environments?view=aspnetcore-2.1 // Logging configuration // https://docs.microsoft.com/en-us/aspnet/core/fundamentals/logging/?view=aspnetcore-2.1 var logConf = Configuration["Logging:IncludeScopes"]; // Std logger //var logger = loggerFactory.CreateLogger(this.GetType()); //logger.LogWarning("Warning"); //var generalLogger = ApplicationLogging.CreateLogger("General"); //generalLogger.LogCritical("from static"); // Questi due, invece, ce li mette già il default bilder in program.cs //loggerFactory.AddConsole(); //loggerFactory.AddDebug(); // Questo è per aggiungere NLog loggerFactory.AddNLog(new NLogProviderOptions { CaptureMessageTemplates = true, CaptureMessageProperties = true }); NLog.LogManager.LoadConfiguration("nlog.config"); // Custom static logger ApplicationLogging.ConfigureLogger(loggerFactory); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler(); } cityInfoContext.EnsureSeedDataForContext(); app.UseStatusCodePages(); app.UseMvc(); //app.Run(async (context) => //{ // StringBuilder sb = new StringBuilder(); // sb.AppendFormat("IsDevelopment: {0} <br/>", env.IsDevelopment()); // sb.AppendFormat("IsProduction: {0} <br/>", env.IsProduction()); // sb.AppendFormat("IsStaging: {0} ", env.IsStaging()); // string output = sb.ToString(); // await context.Response.WriteAsync(output); //}); // If stdoutLogEnabled="true" and stdoutLogFile=".\logs\stdout" in web.config, then // it gets logged Console.WriteLine("Configure called"); }
public TestingDatabaseTable(CityInfoContext cityInfoContext) { this.cityInfoContext = cityInfoContext ?? throw new ArgumentNullException(nameof(cityInfoContext)); }
public CityInfoRepository(CityInfoContext dbContext) { mDbContext = dbContext; }
public static void EnsureSeedDataForContext(this CityInfoContext context) { if (context.Cities.Any()) { return; } //Seeding the data var cities = new List <City>() { new City() { Id = 1, Name = "NewYork", Description = "What ever newyork does", PointsOfInterest = new List <PointOfInterest>() { new PointOfInterest() { Id = 1, Name = "Central Park", Description = "Central park desc" }, new PointOfInterest() { Id = 2, Name = "Empire State Buildinf", Description = "Empire State desc" }, } }, new City() { Id = 2, Name = "Corpus", Description = "What ever Corpus does", PointsOfInterest = new List <PointOfInterest>() { new PointOfInterest() { Id = 3, Name = "TAMUCC", Description = "Tamucc desc" }, new PointOfInterest() { Id = 4, Name = "Dave and busters", Description = "Dave and busters desc" }, } }, new City() { Id = 3, Name = "Hyd", Description = "What ever Hyd does", PointsOfInterest = new List <PointOfInterest>() { new PointOfInterest() { Id = 5, Name = "tank bund", Description = "Tank bund desc" }, new PointOfInterest() { Id = 6, Name = "Gokul Chat", Description = "Gokul Chat desc" }, } } }; context.Cities.AddRange(cities); context.SaveChanges(); }
// 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, CityInfoContext cityInfoContext) { loggerFactory.AddConsole(); loggerFactory.AddDebug(); loggerFactory.AddNLog(); loggerFactory.ConfigureNLog("nlog.config"); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); //adds exception capability handling to the pipeline. } else { app.UseExceptionHandler(); //app.UseExceptionHandler( // options => // { // options.Run( // async context => // { // context.Response.StatusCode = (int)HttpStatusCode.InternalServerError; // context.Response.ContentType = "text/html"; // var ex = context.Features.Get<IExceptionHandlerFeature>(); // if (ex != null) // { // var err = $"<h1>Error: {ex.Error.Message}</h1>{ex.Error.StackTrace }"; // await context.Response.WriteAsync(err).ConfigureAwait(false); // } // }); // } //); } cityInfoContext.EnsureSeedDataForContext(); app.UseStatusCodePages(); //will receive the text based information for status code. AutoMapper.Mapper.Initialize(cfg => { cfg.CreateMap <Entities.City, Models.CityWithoutPointsOfInterestDto>(); 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>(); }); app.UseMvc(); //add the MVC handles HTTP Middleware requests now //app.Run((context) => //{ // throw new Exception("Exception"); //}); //app.Run(async (context) => //{ // await context.Response.WriteAsync("Hello World!"); //}); }
public TestController(CityInfoContext context) { _context = context ?? throw new ArgumentNullException(nameof(context)); }
public static void EnsureSeedDataForContext(this CityInfoContext context) { if (context.Cities.Any()) { return; } var cities = new List <City>() { new City() { Name = "New York City", Description = "The one with that big park.", PointsOfInterest = new List <PointOfInterest>() { new PointOfInterest() { Name = "London park 1 ", Description = "London part detail" }, new PointOfInterest() { Name = "London park 2 ", Description = "London part detail" }, new PointOfInterest() { Name = "London park 3", Description = "London part detail" }, new PointOfInterest() { Name = "London park 4", Description = "London part detail" }, } }, new City() { Name = "London", Description = "The tesdfdaf with that big park.", PointsOfInterest = new List <PointOfInterest>() { new PointOfInterest() { Name = "Leeds park 1 ", Description = "Leeds part detail" }, new PointOfInterest() { Name = "Leeds park 2 ", Description = "Leeds part detail" }, new PointOfInterest() { Name = "Leeds park 3", Description = "London part detail" }, new PointOfInterest() { Name = "Leeds park 4", Description = "London part detail" }, } }, new City() { Name = "Leeds", Description = "The testdfasdf with that big park.", } }; context.Cities.AddRange(cities); context.SaveChanges(); }
public static void EnsureSeedDataForContext(this CityInfoContext context) { if (context.Cities.Any()) { return; } // seed data var cities = new List <City>() { new City() { Name = "New York City", Description = "The one with that big park", PointsOfInterest = new List <PointOfInterest>() { new PointOfInterest() { Name = "Central Park", Description = "The most visited..." }, new PointOfInterest() { Name = "Empire State building", Description = "The highest building in NY..." }, } }, new City() { Name = "Antwerpen", Description = "The one with cathedral that was never finished", PointsOfInterest = new List <PointOfInterest>() { new PointOfInterest() { Name = "Katedrala", Description = "Gotski stil..." }, new PointOfInterest() { Name = "Glavna stanica ", Description = "Barokni stil..." }, } }, new City() { Name = "Paris", Description = "The one with that big tower", PointsOfInterest = new List <PointOfInterest>() { new PointOfInterest() { Name = "Ajfelov toranj", Description = "visok 300 m..." }, new PointOfInterest() { Name = "Luvr ", Description = "Mona Liza..." } } } }; context.Cities.AddRange(cities); context.SaveChanges(); }
public static void EnsureSeedDataForContext(this CityInfoContext context) { if (context.Cities.Any()) { return; } //init seed data var cities = new List <City>() { new City() { Name = "New York City", Description = "Cool place in the NE", PointOfInterests = new List <PointOfInterest>() { new PointOfInterest() { Name = "Central Park", Description = "Famous Park" }, new PointOfInterest() { Name = "Empire State Building", Description = "Famous Building" } } }, new City() { Name = "Miami", Description = "Place I was born", PointOfInterests = new List <PointOfInterest>() { new PointOfInterest() { Name = "South Beach", Description = "Famous Beach" }, new PointOfInterest() { Name = "Hialiah", Description = "Cuban Neighborhood" } } }, new City() { Name = "Seattle", Description = "Place where my parents live", PointOfInterests = new List <PointOfInterest>() { new PointOfInterest() { Name = "Space Needle", Description = "Famous Building" }, new PointOfInterest() { Name = "Bellvue", Description = "Location of Microsoft Headquarters" } } } }; context.Cities.AddRange(cities); context.SaveChanges(); }
// 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, CityInfoContext cityInfoContext) { loggerFactory.AddConsole(); loggerFactory.AddDebug(); loggerFactory.AddNLog(); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } //seed data cityInfoContext.EnsureSeedDataForContext(); //auto mapper AutoMapper.Mapper.Initialize(cfg => { cfg.CreateMap <Entities.City, Models.CityWithooutPointOfIntrestDto>(); cfg.CreateMap <Entities.City, CityDto>(); cfg.CreateMap <Entities.PointOfIntrest, PointOfIntrestDto>(); cfg.CreateMap <PointOfIntrestCreationDto, PointOfIntrest>(); cfg.CreateMap <PointOfIntrestUpdationDto, PointOfIntrest>(); cfg.CreateMap <PointOfIntrest, PointOfIntrestUpdationDto>(); }); app.UseStatusCodePages(); app.UseMvc(); // app.Run(async (context) => // { // await context.Response.WriteAsync("Hello World!"); // }); }
public CitySevice(CityInfoContext context) { this.context = context; }
public PointsOfInterestController(ILogger <PointsOfInterestController> logger, CityInfoContext context) { this.logger = logger; this.context = context; }
public DummyController(CityInfoContext ctx) { _ctx = ctx ?? throw new ArgumentNullException(nameof(ctx)); }
public CityService(CityInfoContext db, IMapper <City, CitityWithOutPointsOfInterestDto> mapper) : base(db, mapper) { }
public static void EnsureSeedDataForContext(this CityInfoContext context) { if (context.Cities.Any()) { return; } var cities = new List <City>() { new City() { Name = "New York City", Description = "The one with that big park.", PointsOfInterest = new List <PointOfInterest>() { new PointOfInterest() { Name = "Central Park", Description = "The most visited urban park in the United States." }, new PointOfInterest() { Name = "Empire State Building", Description = "A 102-story skyscraper located in Midtown Manhattan." }, } }, new City() { Name = "Antwerp", Description = "The one with the cathedral that was never really finished.", PointsOfInterest = new List <PointOfInterest>() { new PointOfInterest() { Name = "Cathedral", Description = "A Gothic style cathedral, conceived by architects Jan and Pieter Appelmans." }, new PointOfInterest() { Name = "Antwerp Central Station", Description = "The the finest example of railway architecture in Belgium." }, } }, new City() { Name = "Paris", Description = "The one with that big tower.", 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.Cities.AddRange(cities); context.SaveChanges(); }
// 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, CityInfoContext cityInfoContext) { loggerFactory.AddConsole(); loggerFactory.AddDebug(); //loggerFactory.AddProvider(new NLog.Extensions.Logging.NLogLoggerProvider()); loggerFactory.AddNLog(); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler(); } cityInfoContext.EnsureSeedDataForContext(); app.UseStatusCodePages(); AutoMapper.Mapper.Initialize(cfg => { cfg.CreateMap <Entities.City, Models.CityWithoutPointsOfInterestDto>(); 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>(); } ); app.UseMvc(); /*app.Run(async (context) => * { * await context.Response.WriteAsync("Hello World!"); * });*/ }
public DummyController(CityInfoContext ctx) { _ctx = ctx; }
public DummyController(CityInfoContext cityInfoContext) { this.cityInfoContext = cityInfoContext ?? throw new ArgumentNullException(nameof(cityInfoContext)); }
public CityInfoRepository(CityInfoContext context) { _context = context; }
public static void EnsureSeedDataForContext(this CityInfoContext context) { if (context.Cities.Any()) { return; } var cities = new List <City>() { new City() { Name = "New York City", Description = "The one with that big park.", PointOfInterest = new List <PointOfInterest>() { new PointOfInterest() { Name = "Central Park", Description = "Most visited urban park in the USA." }, new PointOfInterest() { Name = "Empire State Building", Description = "A 102-story skyscraper." }, } }, new City() { Name = "Antwerp", Description = "The one with the Cathedral that was never really finished.", PointOfInterest = new List <PointOfInterest>() { new PointOfInterest() { Name = "Some Cathedral", Description = "It's half built." }, new PointOfInterest() { Name = "No idea", Description = "Never been." }, } }, new City() { Name = "Paris", Description = "Capital of France", PointOfInterest = new List <PointOfInterest>() { new PointOfInterest() { Name = "Eiffle Tower", Description = "Big metal thing" }, new PointOfInterest() { Name = "Mona Lisa Painting", Description = "A cheeky grin." }, } } }; context.Cities.AddRange(cities); context.SaveChanges(); }