Oliver Booth
e8bc50bbdf
I'd ideally like to keep the blog. subdomain the same, and while there are a few ways to achieve this it is much simpler to just dedicate a separate application for the subdomain. This change also adjusts the webhost builder extensions to default to ports 443/80, and each app now explicitly sets the port it needs.
33 lines
1.0 KiB
C#
33 lines
1.0 KiB
C#
using System.Diagnostics.CodeAnalysis;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using OliverBooth.Blog.Data;
|
|
|
|
namespace OliverBooth.Blog.Services;
|
|
|
|
/// <summary>
|
|
/// Represents an implementation of <see cref="IUserService" />.
|
|
/// </summary>
|
|
internal sealed class UserService : IUserService
|
|
{
|
|
private readonly IDbContextFactory<BlogContext> _dbContextFactory;
|
|
|
|
/// <summary>
|
|
/// Initializes a new instance of the <see cref="UserService" /> class.
|
|
/// </summary>
|
|
/// <param name="dbContextFactory">
|
|
/// The <see cref="IDbContextFactory{TContext}" /> used to create a <see cref="BlogContext" />.
|
|
/// </param>
|
|
public UserService(IDbContextFactory<BlogContext> dbContextFactory)
|
|
{
|
|
_dbContextFactory = dbContextFactory;
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public bool TryGetUser(Guid id, [NotNullWhen(true)] out IUser? user)
|
|
{
|
|
using BlogContext context = _dbContextFactory.CreateDbContext();
|
|
user = context.Users.Find(id);
|
|
return user is not null;
|
|
}
|
|
}
|