/// <summary> /// Sent Email /// </summary> /// <param name="requestModel"></param> /// <returns></returns> public EmailVerificationResponseModel VerifyEmail(EmailVerificationRequestModel requestModel) { EmailVerificationResponseModel responseModel = new EmailVerificationResponseModel(); try { EmailVerifyTokenRepo token = new EmailVerifyTokenRepo(); //Generate Token and Request Id string[] TokenAndRequest = token.AddEmailVerificationToken(requestModel.EmailAddress); string AppendedWebApiPath = AppendPath(TokenAndRequest[0]); //Generate WebApi PAth with Token UserProfileRepo repo = new UserProfileRepo(); string FullName = repo.GetUserName(requestModel.EmailAddress); //Get FirstName and LAstName for Email SendEmailForVerification emailverify = new SendEmailForVerification(); string Body = emailverify.PopulateBody(AppendedWebApiPath, FullName); //Generate Email Template bool IsValid = emailverify.sendHTMLFormattedEmail(requestModel.EmailAddress, Body); //Send Email if (!IsValid) { responseModel.Error = "Service Temporarily Unavailable"; responseModel.IsValid = IsValid; return responseModel; } responseModel.Error = null; responseModel.IsValid = IsValid; responseModel.RequestId = Convert.ToInt32(TokenAndRequest[1]); return responseModel; } catch (TimeoutException) { responseModel.IsValid = false; responseModel.Error = "We cant Process Request At The Moment !!! Kindly try again later"; return responseModel; } catch (WebException) { responseModel.IsValid = false; responseModel.Error = "We cant Process Request At The Moment !!! Kindly try again later"; return responseModel; } }
/// <summary> /// Validation Status /// </summary> /// <param name="requestId"></param> /// <returns></returns> public BaseResponseModel EmailVerificationStatus(int requestId) { BaseResponseModel responseModel = new BaseResponseModel(); EmailVerifyTokenRepo tokenRepo = new EmailVerifyTokenRepo(); bool IsValid = tokenRepo.EmailVerificationStatus(requestId); if (!IsValid) { responseModel.IsValid = IsValid; responseModel.Error = "Not Verified"; return responseModel; } responseModel.IsValid = IsValid; responseModel.Error = null; return responseModel; }
/// <summary> /// Validating Confirmation Link /// </summary> /// <param name="TokenId"></param> /// <returns></returns> public EmailValidationResponseModel VerifyOnToken(string TokenId) { EmailValidationResponseModel responseModel = new EmailValidationResponseModel(); EmailVerifyTokenRepo tokenRepo = new EmailVerifyTokenRepo(); string Message = tokenRepo.EmailVerifyTokenChecker(TokenId); if (Message == null) { responseModel.IsValid = false; responseModel.Error = "InValid Token"; responseModel.Message = null; return responseModel; } responseModel.IsValid = true; responseModel.Error = null; responseModel.Message = Message; return responseModel; }