public async Task <IActionResult> Index([FromServices] AppDbContextFactory factory, long?flatId) { var userId = HttpContext.GetCurrentUserId(); var userName = HttpContext.GetCurrentUserName(); var model = new ReportsModel(); using (var context = factory.CreateContext()) { await model.LoadAsync(context, userId, userName, flatId); } return(View(model)); }