Exemplo n.º 1
0
        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());
            }
        }
Exemplo n.º 2
0
        public Verification GetVerificationByPhoneNumber(string phoneNumber)
        {
            VerificationEntity entity = this.dbContext.Verifications.FirstOrDefault(v => v.PhoneNumber == phoneNumber);

            return(entity == null ? null : entity.ToModel());
        }
Exemplo n.º 3
0
        public Verification GetVerificationById(int id)
        {
            VerificationEntity entity = this.dbContext.Verifications.FirstOrDefault(v => v.Id == id);

            return(entity == null ? null : entity.ToModel());
        }