Example #1
0
        public static void InitializeDbForTests(MyRentalsContext db)
        {
            if (!db.Realtors.Any(a => a.RealtorId == 0))
            {
                db.Realtors.Add(new Realtor(0, "realtor", "*****@*****.**"));
                db.SaveChanges();
            }

            if (!db.Apartments.Any(a => !a.IsRented))
            {
                db.Apartments.Add(new Apartment(0, "Apartment", "desc", 1200, 1400, 3, -0.1m, 50, DateTime.UtcNow,
                                                db.Realtors.First().RealtorId, false));
                db.SaveChanges();
            }
        }
Example #2
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, MyRentalsContext myRentalsContext)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Error");
                // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
                app.UseHsts();
            }

            app.UseHttpsRedirection();
            app.UseStaticFiles();
            app.UseSpaStaticFiles();

            app.UseRouting();
            app.UseAuthentication().UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllerRoute(
                    name: "default",
                    pattern: "{controller}/{action=Index}/{id?}");
            });
            app.UseSwagger();
            app.UseSwaggerUI(c =>
            {
                //c.OAuthClientId("implicit");
                c.SwaggerEndpoint("/swagger/v1/swagger.json", "My API V1");
                c.OAuthConfigObject.ClientId = ClientId;
            });

            app.UseSpa(spa =>
            {
                spa.Options.SourcePath = "ClientApp";

                if (env.IsDevelopment())
                {
                    spa.UseReactDevelopmentServer(npmScript: "dev");
                }
            });
            myRentalsContext.SeedDatabase();
        }
Example #3
0
 public ClientRepository(MyRentalsContext context)
 {
     this.context = context;
 }
Example #4
0
 public ApartmentRepository(MyRentalsContext context)
 {
     this.context = context;
 }
Example #5
0
 public RealtorRepository(MyRentalsContext context)
 {
     this.context = context;
 }