using OFBButte.Application.Database; using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace OFBButte.Application.Users { public class VerifyEmail { private readonly IOFBContext context; public VerifyEmail(IOFBContext context) { this.context = context; } public bool Handle(int codeId, string code) { var dte = DateTime.Now.AddHours(-1); var user = context.Users.FirstOrDefault(u => u.EmailVerificationCode.Id == codeId && u.EmailVerificationCode.Code == code && u.EmailVerifiedDate > dte); if (user == null) return false; user.EmailVerifiedDate = DateTime.Now; context.SaveChanges(); return true; } } }