public Verification AddOrUpdateVerification(Verification verification) { VerificationEntity entity = this.dbContext.Verifications.FirstOrDefault(v => v.PhoneNumber == verification.PhoneNumber); if (entity == null) { entity = verification.ToEntity(); this.dbContext.Verifications.Add(entity); this.dbContext.SaveChanges(); return(entity.ToModel()); } else { entity.StartTime = DateTime.Now; entity.Code = verification.Code; this.dbContext.SaveChanges(); return(entity.ToModel()); } }
public Verification GetVerificationByPhoneNumber(string phoneNumber) { VerificationEntity entity = this.dbContext.Verifications.FirstOrDefault(v => v.PhoneNumber == phoneNumber); return(entity == null ? null : entity.ToModel()); }
public Verification GetVerificationById(int id) { VerificationEntity entity = this.dbContext.Verifications.FirstOrDefault(v => v.Id == id); return(entity == null ? null : entity.ToModel()); }