Skip to content

Commit

Permalink
stormideas#6. get lists where user is responsible party in one of the…
Browse files Browse the repository at this point in the history
… tasks. Log sql to console as traces.
  • Loading branch information
Paweł Pawelec committed Dec 5, 2021
1 parent a076670 commit 6957bf7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Todo/Services/ApplicationDbContextConvenience.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public static IQueryable<TodoList> RelevantTodoLists(this ApplicationDbContext d
{
return dbContext.TodoLists.Include(tl => tl.Owner)
.Include(tl => tl.Items)
.Where(tl => tl.Owner.Id == userId);
.Where(tl => tl.Owner.Id == userId || tl.Items.Any(item => item.ResponsiblePartyId == userId));
}

public static TodoList SingleTodoList(this ApplicationDbContext dbContext, int todoListId)
Expand Down
14 changes: 9 additions & 5 deletions Todo/Startup.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Microsoft.AspNetCore.Authorization;
using System;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Hosting;
Expand All @@ -8,6 +9,7 @@
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;

namespace Todo
{
Expand All @@ -31,8 +33,10 @@ public void ConfigureServices(IServiceCollection services)
});

services.AddDbContext<ApplicationDbContext>(options =>
options.UseSqlite(
Configuration.GetConnectionString("DefaultConnection")));
{
options.LogTo(Console.WriteLine, LogLevel.Trace);
options.UseSqlite(Configuration.GetConnectionString("DefaultConnection"));
});

services.AddDefaultIdentity<IdentityUser>(options => options.SignIn.RequireConfirmedAccount = false)
.AddEntityFrameworkStores<ApplicationDbContext>();
Expand All @@ -53,7 +57,7 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
app.UseRouting();
app.UseWebOptimizer();

if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
Expand All @@ -78,4 +82,4 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
});
}
}
}
}
2 changes: 1 addition & 1 deletion Todo/appsettings.Development.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"Logging": {
"LogLevel": {
"Default": "Debug",
"Default": "Trace",
"System": "Information",
"Microsoft": "Information"
}
Expand Down

0 comments on commit 6957bf7

Please sign in to comment.