namespace MyOffice.Data.Repositories.Item;

using Microsoft.EntityFrameworkCore;
using MyOffice.Data.Models.Verifications;
using MyOffice.DbContext;

public class VerificationCodeRepository : AppRepository<VerificationCode>, IVerificationCodeRepository
{
	public VerificationCodeRepository(AppDbContext context) : base(context)
	{
	}

	public bool Add(VerificationCode entity)
	{
		return AddBase(entity) > 0;
	}

	public bool Update(VerificationCode entity)
	{
		return UpdateBase(entity) > 0;
	}

	public VerificationCode? GetByCode(string code)
	{
		return _context.Verifications.FirstOrDefault(x => x.Code == code);
	}
}