Example #1
0
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, StockMarketContext stockMarketContext)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler(appBuilder =>
                {
                    appBuilder.Run(async context =>
                    {
                        var exceptionHandlerFeature = context.Features.Get <IExceptionHandlerFeature>();
                        if (exceptionHandlerFeature != null)
                        {
                            var logger = loggerFactory.CreateLogger("Global exception logger");
                            logger.LogError(500,
                                            exceptionHandlerFeature.Error,
                                            exceptionHandlerFeature.Error.Message);
                        }

                        context.Response.StatusCode = 500;
                        await context.Response.WriteAsync("An unexpected fault happened. Try again later.");
                    });
                });
            }

            app.UseCors(builder => builder
                        .AllowAnyOrigin()
                        .AllowAnyMethod()
                        .AllowAnyHeader()
                        .AllowCredentials());

            Mapper.Initialize(cfg =>
            {
                cfg.CreateMap <Client, ClientDto>();
                cfg.CreateMap <ClientForCreationDto, Client>();
                cfg.CreateMap <ClientForUpdateDto, Client>();

                cfg.CreateMap <Stock, StockDto>();
                cfg.CreateMap <StockForCreationDto, Stock>();
                cfg.CreateMap <StockForUpdateDto, Stock>();

                cfg.CreateMap <Order, OrderDto>();
                cfg.CreateMap <OrderDto, Order>();
                cfg.CreateMap <OrderForCreationDto, Order>();
            });

            app.UseSwagger();

            app.UseSwaggerUI(c =>
            {
                c.SwaggerEndpoint("/swagger/v1/swagger.json", "Stock Market Register API V1");
            });

            stockMarketContext.EnsureSeedDataForContext();
            app.UseMvc();
        }
 public void Setup()
 {
     context = new StockMarketContext(options);
     context.Sectors.AddRange(GetSectorList());
     context.SaveChanges();
 }
 public StockRepository(StockMarketContext context)
 {
     _context = context;
 }
Example #4
0
 public UploadRepository(StockMarketContext dbContext)
 {
     this.context = dbContext;
 }
Example #5
0
 public StockpriceRepository(StockMarketContext context)
 {
     this.context = context;
 }
Example #6
0
 public IAdminInterface()
 {
     db = new StockMarketContext();
 }
 public StockExchangeRepository(StockMarketContext context)
 {
     this.context = context;
 }
Example #8
0
 public IUserInterface()
 {
     db = new StockMarketContext();
 }
Example #9
0
 public StockData(StockMarketContext context)
 {
     _context = context;
 }
 public CompanyRepository(StockMarketContext context)
 {
     this.context = context;
 }
 public UserRepository(StockMarketContext context, IConfiguration configuration)
 {
     this.context       = context;
     this.configuration = configuration;
 }
 public Company2Repository(StockMarketContext context)
 {
     _context = context;
 }
 public IPORepository(StockMarketContext context)
 {
     this.context = context;
 }
Example #14
0
 public UserAccountData(StockMarketContext context)
 {
     _context = context;
 }