public sealed class IssueService : IIssueService{ private readonly AppDbContext _db; private readonly ILogger _log; public async Task<Result<Issue>> Create( CreateIssue cmd, CancellationToken ct) { var project = await _db.Projects .FindAsync([cmd.ProjectId], ct); if (project is null) return Result.NotFound("project"); var issue = new Issue { Title = cmd.Title.Trim(), Status = Status.Backlog, CreatedAt = DateTimeOffset.UtcNow, }; project.Issues.Add(issue); await _db.SaveChangesAsync(ct); _log.LogInformation("issue {Id}", issue.Id); return Result.Ok(issue); }} app.MapGet("/issues/{id}", async ( Guid id, IIssueService svc) => await svc.GetAsync(id) is { } i ? Results.Ok(i) : Results.NotFound()); builder.Services .AddScoped<IIssueService, IssueService>() .AddDbContext<AppDbContext>(o => o.UseNpgsql(cfg.Conn("Default"))); public sealed class IssueService : IIssueService{ private readonly AppDbContext _db; private readonly ILogger _log; public async Task<Result<Issue>> Create( CreateIssue cmd, CancellationToken ct) { var project = await _db.Projects .FindAsync([cmd.ProjectId], ct); if (project is null) return Result.NotFound("project"); var issue = new Issue { Title = cmd.Title.Trim(), Status = Status.Backlog, CreatedAt = DateTimeOffset.UtcNow, }; project.Issues.Add(issue); await _db.SaveChangesAsync(ct); _log.LogInformation("issue {Id}", issue.Id); return Result.Ok(issue); }} app.MapGet("/issues/{id}", async ( Guid id, IIssueService svc) => await svc.GetAsync(id) is { } i ? Results.Ok(i) : Results.NotFound()); builder.Services .AddScoped<IIssueService, IssueService>() .AddDbContext<AppDbContext>(o => o.UseNpgsql(cfg.Conn("Default"))); public sealed class IssueService : IIssueService{ private readonly AppDbContext _db; private readonly ILogger _log; public async Task<Result<Issue>> Create( CreateIssue cmd, CancellationToken ct) { var project = await _db.Projects .FindAsync([cmd.ProjectId], ct); if (project is null) return Result.NotFound("project"); var issue = new Issue { Title = cmd.Title.Trim(), Status = Status.Backlog, CreatedAt = DateTimeOffset.UtcNow, }; project.Issues.Add(issue); await _db.SaveChangesAsync(ct); _log.LogInformation("issue {Id}", issue.Id); return Result.Ok(issue); }} app.MapGet("/issues/{id}", async ( Guid id, IIssueService svc) => await svc.GetAsync(id) is { } i ? Results.Ok(i) : Results.NotFound()); builder.Services .AddScoped<IIssueService, IssueService>() .AddDbContext<AppDbContext>(o => o.UseNpgsql(cfg.Conn("Default"))); public sealed class IssueService : IIssueService{ private readonly AppDbContext _db; private readonly ILogger _log; public async Task<Result<Issue>> Create( CreateIssue cmd, CancellationToken ct) { var project = await _db.Projects .FindAsync([cmd.ProjectId], ct); if (project is null) return Result.NotFound("project"); var issue = new Issue { Title = cmd.Title.Trim(), Status = Status.Backlog, CreatedAt = DateTimeOffset.UtcNow, }; project.Issues.Add(issue); await _db.SaveChangesAsync(ct); _log.LogInformation("issue {Id}", issue.Id); return Result.Ok(issue); }} app.MapGet("/issues/{id}", async ( Guid id, IIssueService svc) => await svc.GetAsync(id) is { } i ? Results.Ok(i) : Results.NotFound()); builder.Services .AddScoped<IIssueService, IssueService>() .AddDbContext<AppDbContext>(o => o.UseNpgsql(cfg.Conn("Default"))); public sealed class IssueService : IIssueService{ private readonly AppDbContext _db; private readonly ILogger _log; public async Task<Result<Issue>> Create( CreateIssue cmd, CancellationToken ct) { var project = await _db.Projects .FindAsync([cmd.ProjectId], ct); if (project is null) return Result.NotFound("project"); var issue = new Issue { Title = cmd.Title.Trim(), Status = Status.Backlog, CreatedAt = DateTimeOffset.UtcNow, }; project.Issues.Add(issue); await _db.SaveChangesAsync(ct); _log.LogInformation("issue {Id}", issue.Id); return Result.Ok(issue); }} app.MapGet("/issues/{id}", async ( Guid id, IIssueService svc) => await svc.GetAsync(id) is { } i ? Results.Ok(i) : Results.NotFound()); builder.Services .AddScoped<IIssueService, IssueService>() .AddDbContext<AppDbContext>(o => o.UseNpgsql(cfg.Conn("Default"))); public sealed class IssueService : IIssueService{ private readonly AppDbContext _db; private readonly ILogger _log; public async Task<Result<Issue>> Create( CreateIssue cmd, CancellationToken ct) { var project = await _db.Projects .FindAsync([cmd.ProjectId], ct); if (project is null) return Result.NotFound("project"); var issue = new Issue { Title = cmd.Title.Trim(), Status = Status.Backlog, CreatedAt = DateTimeOffset.UtcNow, }; project.Issues.Add(issue); await _db.SaveChangesAsync(ct); _log.LogInformation("issue {Id}", issue.Id); return Result.Ok(issue); }} app.MapGet("/issues/{id}", async ( Guid id, IIssueService svc) => await svc.GetAsync(id) is { } i ? Results.Ok(i) : Results.NotFound()); builder.Services .AddScoped<IIssueService, IssueService>() .AddDbContext<AppDbContext>(o => o.UseNpgsql(cfg.Conn("Default"))); public sealed class IssueService : IIssueService{ private readonly AppDbContext _db; private readonly ILogger _log; public async Task<Result<Issue>> Create( CreateIssue cmd, CancellationToken ct) { var project = await _db.Projects .FindAsync([cmd.ProjectId], ct); if (project is null) return Result.NotFound("project"); var issue = new Issue { Title = cmd.Title.Trim(), Status = Status.Backlog, CreatedAt = DateTimeOffset.UtcNow, }; project.Issues.Add(issue); await _db.SaveChangesAsync(ct); _log.LogInformation("issue {Id}", issue.Id); return Result.Ok(issue); }} app.MapGet("/issues/{id}", async ( Guid id, IIssueService svc) => await svc.GetAsync(id) is { } i ? Results.Ok(i) : Results.NotFound()); builder.Services .AddScoped<IIssueService, IssueService>() .AddDbContext<AppDbContext>(o => o.UseNpgsql(cfg.Conn("Default"))); public sealed class IssueService : IIssueService{ private readonly AppDbContext _db; private readonly ILogger _log; public async Task<Result<Issue>> Create( CreateIssue cmd, CancellationToken ct) { var project = await _db.Projects .FindAsync([cmd.ProjectId], ct); if (project is null) return Result.NotFound("project"); var issue = new Issue { Title = cmd.Title.Trim(), Status = Status.Backlog, CreatedAt = DateTimeOffset.UtcNow, }; project.Issues.Add(issue); await _db.SaveChangesAsync(ct); _log.LogInformation("issue {Id}", issue.Id); return Result.Ok(issue); }} app.MapGet("/issues/{id}", async ( Guid id, IIssueService svc) => await svc.GetAsync(id) is { } i ? Results.Ok(i) : Results.NotFound()); builder.Services .AddScoped<IIssueService, IssueService>() .AddDbContext<AppDbContext>(o => o.UseNpgsql(cfg.Conn("Default"))); public sealed class IssueService : IIssueService{ private readonly AppDbContext _db; private readonly ILogger _log; public async Task<Result<Issue>> Create( CreateIssue cmd, CancellationToken ct) { var project = await _db.Projects .FindAsync([cmd.ProjectId], ct); if (project is null) return Result.NotFound("project"); var issue = new Issue { Title = cmd.Title.Trim(), Status = Status.Backlog, CreatedAt = DateTimeOffset.UtcNow, }; project.Issues.Add(issue); await _db.SaveChangesAsync(ct); _log.LogInformation("issue {Id}", issue.Id); return Result.Ok(issue); }} app.MapGet("/issues/{id}", async ( Guid id, IIssueService svc) => await svc.GetAsync(id) is { } i ? Results.Ok(i) : Results.NotFound()); builder.Services .AddScoped<IIssueService, IssueService>() .AddDbContext<AppDbContext>(o => o.UseNpgsql(cfg.Conn("Default"))); public sealed class IssueService : IIssueService{ private readonly AppDbContext _db; private readonly ILogger _log; public async Task<Result<Issue>> Create( CreateIssue cmd, CancellationToken ct) { var project = await _db.Projects .FindAsync([cmd.ProjectId], ct); if (project is null) return Result.NotFound("project"); var issue = new Issue { Title = cmd.Title.Trim(), Status = Status.Backlog, CreatedAt = DateTimeOffset.UtcNow, }; project.Issues.Add(issue); await _db.SaveChangesAsync(ct); _log.LogInformation("issue {Id}", issue.Id); return Result.Ok(issue); }} app.MapGet("/issues/{id}", async ( Guid id, IIssueService svc) => await svc.GetAsync(id) is { } i ? Results.Ok(i) : Results.NotFound()); builder.Services .AddScoped<IIssueService, IssueService>() .AddDbContext<AppDbContext>(o => o.UseNpgsql(cfg.Conn("Default"))); public sealed class IssueService : IIssueService{ private readonly AppDbContext _db; private readonly ILogger _log; public async Task<Result<Issue>> Create( CreateIssue cmd, CancellationToken ct) { var project = await _db.Projects .FindAsync([cmd.ProjectId], ct); if (project is null) return Result.NotFound("project"); var issue = new Issue { Title = cmd.Title.Trim(), Status = Status.Backlog, CreatedAt = DateTimeOffset.UtcNow, }; project.Issues.Add(issue); await _db.SaveChangesAsync(ct); _log.LogInformation("issue {Id}", issue.Id); return Result.Ok(issue); }} app.MapGet("/issues/{id}", async ( Guid id, IIssueService svc) => await svc.GetAsync(id) is { } i ? Results.Ok(i) : Results.NotFound()); builder.Services .AddScoped<IIssueService, IssueService>() .AddDbContext<AppDbContext>(o => o.UseNpgsql(cfg.Conn("Default"))); public sealed class IssueService : IIssueService{ private readonly AppDbContext _db; private readonly ILogger _log; public async Task<Result<Issue>> Create( CreateIssue cmd, CancellationToken ct) { var project = await _db.Projects .FindAsync([cmd.ProjectId], ct); if (project is null) return Result.NotFound("project"); var issue = new Issue { Title = cmd.Title.Trim(), Status = Status.Backlog, CreatedAt = DateTimeOffset.UtcNow, }; project.Issues.Add(issue); await _db.SaveChangesAsync(ct); _log.LogInformation("issue {Id}", issue.Id); return Result.Ok(issue); }} app.MapGet("/issues/{id}", async ( Guid id, IIssueService svc) => await svc.GetAsync(id) is { } i ? Results.Ok(i) : Results.NotFound()); builder.Services .AddScoped<IIssueService, IssueService>() .AddDbContext<AppDbContext>(o => o.UseNpgsql(cfg.Conn("Default"))); public sealed class IssueService : IIssueService{ private readonly AppDbContext _db; private readonly ILogger _log; public async Task<Result<Issue>> Create( CreateIssue cmd, CancellationToken ct) { var project = await _db.Projects .FindAsync([cmd.ProjectId], ct); if (project is null) return Result.NotFound("project"); var issue = new Issue { Title = cmd.Title.Trim(), Status = Status.Backlog, CreatedAt = DateTimeOffset.UtcNow, }; project.Issues.Add(issue); await _db.SaveChangesAsync(ct); _log.LogInformation("issue {Id}", issue.Id); return Result.Ok(issue); }} app.MapGet("/issues/{id}", async ( Guid id, IIssueService svc) => await svc.GetAsync(id) is { } i ? Results.Ok(i) : Results.NotFound()); builder.Services .AddScoped<IIssueService, IssueService>() .AddDbContext<AppDbContext>(o => o.UseNpgsql(cfg.Conn("Default"))); public sealed class IssueService : IIssueService{ private readonly AppDbContext _db; private readonly ILogger _log; public async Task<Result<Issue>> Create( CreateIssue cmd, CancellationToken ct) { var project = await _db.Projects .FindAsync([cmd.ProjectId], ct); if (project is null) return Result.NotFound("project"); var issue = new Issue { Title = cmd.Title.Trim(), Status = Status.Backlog, CreatedAt = DateTimeOffset.UtcNow, }; project.Issues.Add(issue); await _db.SaveChangesAsync(ct); _log.LogInformation("issue {Id}", issue.Id); return Result.Ok(issue); }} app.MapGet("/issues/{id}", async ( Guid id, IIssueService svc) => await svc.GetAsync(id) is { } i ? Results.Ok(i) : Results.NotFound()); builder.Services .AddScoped<IIssueService, IssueService>() .AddDbContext<AppDbContext>(o => o.UseNpgsql(cfg.Conn("Default"))); public sealed class IssueService : IIssueService{ private readonly AppDbContext _db; private readonly ILogger _log; public async Task<Result<Issue>> Create( CreateIssue cmd, CancellationToken ct) { var project = await _db.Projects .FindAsync([cmd.ProjectId], ct); if (project is null) return Result.NotFound("project"); var issue = new Issue { Title = cmd.Title.Trim(), Status = Status.Backlog, CreatedAt = DateTimeOffset.UtcNow, }; project.Issues.Add(issue); await _db.SaveChangesAsync(ct); _log.LogInformation("issue {Id}", issue.Id); return Result.Ok(issue); }} app.MapGet("/issues/{id}", async ( Guid id, IIssueService svc) => await svc.GetAsync(id) is { } i ? Results.Ok(i) : Results.NotFound()); builder.Services .AddScoped<IIssueService, IssueService>() .AddDbContext<AppDbContext>(o => o.UseNpgsql(cfg.Conn("Default"))); public sealed class IssueService : IIssueService{ private readonly AppDbContext _db; private readonly ILogger _log; public async Task<Result<Issue>> Create( CreateIssue cmd, CancellationToken ct) { var project = await _db.Projects .FindAsync([cmd.ProjectId], ct); if (project is null) return Result.NotFound("project"); var issue = new Issue { Title = cmd.Title.Trim(), Status = Status.Backlog, CreatedAt = DateTimeOffset.UtcNow, }; project.Issues.Add(issue); await _db.SaveChangesAsync(ct); _log.LogInformation("issue {Id}", issue.Id); return Result.Ok(issue); }} app.MapGet("/issues/{id}", async ( Guid id, IIssueService svc) => await svc.GetAsync(id) is { } i ? Results.Ok(i) : Results.NotFound()); builder.Services .AddScoped<IIssueService, IssueService>() .AddDbContext<AppDbContext>(o => o.UseNpgsql(cfg.Conn("Default"))); public sealed class IssueService : IIssueService{ private readonly AppDbContext _db; private readonly ILogger _log; public async Task<Result<Issue>> Create( CreateIssue cmd, CancellationToken ct) { var project = await _db.Projects .FindAsync([cmd.ProjectId], ct); if (project is null) return Result.NotFound("project"); var issue = new Issue { Title = cmd.Title.Trim(), Status = Status.Backlog, CreatedAt = DateTimeOffset.UtcNow, }; project.Issues.Add(issue); await _db.SaveChangesAsync(ct); _log.LogInformation("issue {Id}", issue.Id); return Result.Ok(issue); }} app.MapGet("/issues/{id}", async ( Guid id, IIssueService svc) => await svc.GetAsync(id) is { } i ? Results.Ok(i) : Results.NotFound()); builder.Services .AddScoped<IIssueService, IssueService>()