using System.Diagnostics.CodeAnalysis; using Microsoft.EntityFrameworkCore; using OliverBooth.Data.Blog; namespace OliverBooth.Services; /// /// Represents an implementation of . /// internal sealed class BlogUserService : IBlogUserService { private readonly IDbContextFactory _dbContextFactory; /// /// Initializes a new instance of the class. /// /// /// The used to create a . /// public BlogUserService(IDbContextFactory dbContextFactory) { _dbContextFactory = dbContextFactory; } /// 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; } }