public MobileSecondHandContextForTestsFixture()
 {
     MobileSecondHandContextOptions = new MobileSecondHandContextOptions(new ConnectionStringConfig()
     {
         ConnectionString = "Server=.\\SQLEXPRESS;Database=MobileSecondHandNew_TESTS;Integrated Security=SSPI;Trusted_Connection=True;MultipleActiveResultSets=true"
     });
     DbContext = new MobileSecondHandContext(MobileSecondHandContextOptions.DbContextOptions);
     DbContext.Database.EnsureCreated();
 }
		public MobileSecondHandContextForTestsFixture()
		{
			MobileSecondHandContextOptions = new MobileSecondHandContextOptions(new ConnectionStringConfig() { ConnectionString = "Server=.\\SQLEXPRESS;Database=MobileSecondHandNew_TESTS;Integrated Security=SSPI;Trusted_Connection=True;MultipleActiveResultSets=true" });
			DbContext = new MobileSecondHandContext(MobileSecondHandContextOptions.DbContextOptions);
			DbContext.Database.EnsureCreated();
		}
 public FakeController(MobileSecondHandContext context)
 {
     this.context = context;
 }
 public AdvertisementItemDbService(MobileSecondHandContext context)
 {
     this.dbContext = context;
 }
 public ConversationDbService(IMobileSecondHandContextOptions mobileSecondHandContextOptions)
 {
     dbContextOptions = mobileSecondHandContextOptions.DbContextOptions;
     this.dbContext   = new MobileSecondHandContext(mobileSecondHandContextOptions.DbContextOptions);
 }
 private void SaveChangesAndRecreateContext()
 {
     this.dbContext.SaveChanges();
     this.dbContext = new MobileSecondHandContext(dbContextOptions);
 }
		public AdvertisementItemDbService(MobileSecondHandContext context) {
			this.dbContext = context;
		}
Esempio n. 8
0
        private void CreateCategories(MobileSecondHandContext dbCtx)
        {
            dbCtx.Category.AddRange(
                new Category
            {
                Name = "Buty"
            },
                new Category
            {
                Name = "Bluzy"
            },
                new Category
            {
                Name = "Bluzki"
            },
                new Category
            {
                Name = "Dresy"
            },
                new Category
            {
                Name = "Fartuchy kuchenne"
            },
                new Category
            {
                Name = "Garsonki/Kostiumy"
            },
                new Category
            {
                Name = "Golfy"
            },
                new Category
            {
                Name = "Kombinezony"
            },
                new Category
            {
                Name = "Koszule"
            },
                new Category
            {
                Name = "Kurtki/Płaszcze"
            },
                new Category
            {
                Name = "Legginsy"
            },
                new Category
            {
                Name = "Marynarki/Żakiety"
            },
                new Category
            {
                Name = "Materiały krawieckie"
            },
                new Category
            {
                Name = "Odzież dziecięca"
            },
                new Category
            {
                Name = "Spódnice/Spódniczki"
            },
                new Category
            {
                Name = "Stroje kąpielowe"
            },
                new Category
            {
                Name = "Sukienki"
            },
                new Category
            {
                Name = "Swetry"
            },
                new Category
            {
                Name = "Torby/Walizki turystyczne"
            },
                new Category
            {
                Name = "Torebki"
            },
                new Category
            {
                Name = "T-Shirty/Koszulki"
            },
                new Category
            {
                Name = "Tuniki"
            },
                new Category
            {
                Name = "Inne"
            });

            dbCtx.SaveChanges();
        }
Esempio n. 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, TokenAuthorizationOptions tokenAuthorizationOptions, IMobileSecondHandContextOptions contextOptions)
        {
            loggerFactory.AddDebug();
            loggerFactory.AddNLog();
            app.UseApplicationInsightsRequestTelemetry();
            env.ConfigureNLog("nlog.config");
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseDatabaseErrorPage();
                app.UseBrowserLink();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");

                // For more details on creating database during deployment see http://go.microsoft.com/fwlink/?LinkID=615859
                try
                {
                    using (var serviceScope = app.ApplicationServices.GetRequiredService <IServiceScopeFactory>()
                                              .CreateScope())
                    {
                        serviceScope.ServiceProvider.GetService <MobileSecondHandContext>()
                        .Database.Migrate();
                    }
                }
                catch { }
            }

            var dbCtx    = new MobileSecondHandContext(contextOptions.DbContextOptions);
            var category = dbCtx.Category.FirstOrDefault();

            if (category == null)
            {
                CreateCategories(dbCtx);
            }

            app.UseApplicationInsightsExceptionTelemetry();

            app.UseStaticFiles();

            app.Use(next => async ctx =>
            {
                try
                {
                    await next(ctx);
                }
                catch (Exception exc)
                {
                    if (ctx.Response.HasStarted)
                    {
                        throw exc;
                    }

                    ctx.Response.StatusCode = 401;
                }
            });

            app.UseJwtBearerAuthentication(GetJwtBearerOptions(tokenAuthorizationOptions));

            app.UseIdentity();

            app.UseFacebookAuthentication(GetFacebookOptions(Configuration));
            // Add external authentication middleware below. To configure them please see http://go.microsoft.com/fwlink/?LinkID=532715

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");
            });

            app.UseCors("myPolicy");

            app.UseSignalR();
            //app.UseWebSockets();
        }
 public KeywordsDbService(MobileSecondHandContext dbContext)
 {
     this.dbContext = dbContext;
 }
Esempio n. 11
0
 public FeedbackDbService(MobileSecondHandContext context)
 {
     this.context = context;
 }
		public ConversationDbService(IMobileSecondHandContextOptions mobileSecondHandContextOptions)
		{
			this.dbContext = new MobileSecondHandContext(mobileSecondHandContextOptions.DbContextOptions);
		}
Esempio n. 13
0
 public CategoryDbService(MobileSecondHandContext dbContext)
 {
     this.dbContext = dbContext;
 }