1234567891011121314151617181920212223242526272829303132333435363738 |
- 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<LoginOTP>, ILoginOTPRepository
- {
- private readonly DbSet<LoginOTP> dbSet;
- public LoginOTPRepository(HRDataContext context) : base(context)
- {
- dbSet = context.Set<LoginOTP>();
- }
- public async Task<bool> 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<string> LastOpt()
- {
- var res= await dbSet.OrderByDescending(x=>x.CreateDate).FirstOrDefaultAsync();
- return res.OTP;
- }
- }
- }
|