Example #1
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, RemindMealContext context)
        {
            Console.WriteLine($"Startup: Environment is {env.EnvironmentName}");
            if (env.IsDevelopment())
            {
                Console.WriteLine("Using Developer Page and DB error page");
                app.UseDeveloperExceptionPage();
                app.UseMigrationsEndPoint();
            }
            else
            {
                var db = app.ApplicationServices.GetRequiredService <RemindMealContext>();
                db.Database.Migrate();
                app.UseExceptionHandler("/Error");
                app.UseHsts();
            }

            app.UseHttpsRedirection();

            app.UseStaticFiles();
            app.UseCookiePolicy();

            app.UseRouting();

            app.UseForwardedHeaders(new ForwardedHeadersOptions
            {
                ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto
            });
            app.UseAuthentication();
            app.UseAuthorization();

            app.UseEndpoints(endpoints => {
                endpoints.MapRazorPages();
            });
        }
Example #2
0
 public DeleteModel(RemindMealContext context)
 {
     _context = context;
 }
Example #3
0
 public CreateModel(RemindMealContext context, IMapper mapper)
 {
     _context = context;
     _mapper  = mapper;
 }
Example #4
0
 public IndexModel(RemindMealContext context)
 {
     _context = context;
 }
Example #5
0
 public User GetCurrentSessionUser(RemindMealContext context) => _user;
        public User GetCurrentSessionUser(RemindMealContext context)
        {
            string userName = _httpContextAccessor.HttpContext.User?.Identity?.Name;

            return(context.Users.SingleOrDefault(user => user.UserName == userName));
        }
Example #7
0
 public DetailsModel(RemindMealContext context, IMapper mapper)
 {
     _context = context;
     _mapper  = mapper;
 }
Example #8
0
 public IndexModel(RemindMealContext context, UserManager <User> userManager)
 {
     _context     = context;
     _userManager = userManager;
 }
Example #9
0
 public DetailsModel(RemindMealContext context)
 {
     _context = context;
 }
Example #10
0
 public EditModel(RemindMealContext context)
 {
     _context = context;
 }
Example #11
0
 public EditModel(RemindMealContext context, IMapper mapper)
 {
     _context    = context;
     this.mapper = mapper;
 }