using Microsoft.AspNetCore.Identity; using Microsoft.EntityFrameworkCore; using MTWorkHR.Core.Entities; using MTWorkHR.Core.IRepositories; using MTWorkHR.Infrastructure.DBContext; using Org.BouncyCastle.Math.EC.Rfc7748; using System; using System.Collections.Generic; using System.Linq; using System.Linq.Dynamic.Core; using System.Text; using System.Threading.Tasks; namespace MTWorkHR.Infrastructure.Repositories { public class LoginOTPRepository : Repository, ILoginOTPRepository { private readonly DbSet dbSet; public LoginOTPRepository(HRDataContext context) : base(context) { dbSet = context.Set(); } public async Task VerifyOTP(string userId, string oTP) { bool result = false; var loginOTP = await dbSet.AsQueryable().OrderByDescending(x => x.CreateDate).FirstOrDefaultAsync(x => x.UserId == userId && x.ExpireDate >= DateTime.Now); if (loginOTP.OTP == oTP) result = true; return result; } public async Task LastOpt() { var res= await dbSet.OrderByDescending(x=>x.CreateDate).FirstOrDefaultAsync(); return res.OTP; } } }