using Microsoft.EntityFrameworkCore;
using Modules.User.Database.Database;
using Modules.User.Database.Database.Entities;
using System;
using System.Linq.Expressions;

namespace Modules.User.Database.Repositories;

public class AccountRepository(UserDbContext context)
{
    private readonly UserDbContext _context = context;

    internal async Task<bool> AnyWhere(Expression<Func<Account, bool>> predicate) =>
        await _context.Accounts.AnyAsync(predicate);

    internal async Task<Account?> GetFirstOrDefaultWhere(Expression<Func<Account, bool>> predicate) =>
        await _context.Accounts.FirstOrDefaultAsync(predicate);

    internal async Task<Account> GetFirstWhere(Expression<Func<Account, bool>> predicate) =>
        await _context.Accounts.FirstAsync(predicate);

    internal async Task UpdateAccountAsync() => await _context.SaveChangesAsync();
}