コード例 #1
0
 public RentsController(car_sharingContext context, CacheProvider cacheProvider)
 {
     db    = context;
     cache = cacheProvider;
 }
コード例 #2
0
 public AdditionalServicesController(car_sharingContext context, CacheProvider cacheProvider)
 {
     db    = context;
     cache = cacheProvider;
 }
コード例 #3
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, car_sharingContext db)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseSession();

            app.Map("/info", Info);
            app.Map("/carmodels", CarModels);
            app.Map("/cars", Cars);
            app.Map("/employees", Employees);

            app.Map("/searchform", SearchForm);
            app.Run(async(context) =>
            {
                ICachedCarModelsService cachedCarModels = context.RequestServices.GetService <ICachedCarModelsService>();
                cachedCarModels.GetCarModels("carmodels20");

                ICachedEmployeesService cachedEmployeesService = context.RequestServices.GetService <ICachedEmployeesService>();
                cachedEmployeesService.GetEmployees("employees20");

                ICachedCarsService cachedCarsService = context.RequestServices.GetService <ICachedCarsService>();
                cachedCarsService.GetCars("cars20");

                User user = context.Session.Get <User>("user") ?? new User();

                string htmlString = "<html>" +
                                    "<head>" +
                                    "<title>Форма пользователя</title>" +
                                    "<style>" +
                                    "div { font-size: 24; }" +
                                    "</style>" +
                                    "</head>" +
                                    "<meta charset='utf-8'/>" +
                                    "<body>" +
                                    "<div align='center'>" +
                                    "<form action='/'>" +
                                    "<div>Введите логин:</div>";
                htmlString += $"<div><input type='text' name='loginStr' value=" + user.Login + "></div>";
                htmlString += "<div>Введите пароль:</div>";
                htmlString += $"<div><input type='text' name='passwordStr' value=" + user.Password + "></div>" +
                              "<div><input type='submit' value='Enter/Update'></div>" +
                              "</form>" +
                              "<div><a href='/carmodels'>Table 'CarModels'</a></div>" +
                              "<div><a href='/employees'>Table 'Employees'</a></div>" +
                              "<div><a href='/cars'>Table 'Cars'</a></div>" +
                              "<div><a href='/searchform'>Search Form</a></div>" +
                              "</div>" +
                              "</body>" +
                              "</html>";

                string Login    = context.Request.Query["loginStr"];
                string Password = context.Request.Query["passwordStr"];

                if (Login != null && Password != null)
                {
                    user.Login    = Login;
                    user.Password = Password;
                    context.Session.Set <User>("user", user);
                }

                await context.Response.WriteAsync(htmlString);
            });
        }
コード例 #4
0
 public CachedCarModelsService(car_sharingContext context, IMemoryCache memoryCache)
 {
     db    = context;
     cache = memoryCache;
 }
コード例 #5
0
 public CachedEmployeesService(car_sharingContext context, IMemoryCache memoryCache)
 {
     db    = context;
     cache = memoryCache;
 }