/// <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> /// Adding User and Adding Installation /// </summary> /// <param name="requestModel"></param> /// <returns></returns> #region CreateAccount public CreateAccountResponseModel CreateAccount(CreateAccountRequestModel requestModel) { CreateAccountResponseModel responseModel = new CreateAccountResponseModel(); InputValidator validator = new InputValidator(); if(requestModel.ApplicationId == 1) { if (!validator.ValidatePhoneNumber(requestModel.PhoneNumber) || !validator.ValidateProfession(requestModel.Profession)) { responseModel.IsValid = false; return responseModel; } } else { if (!validator.ValidateEmail(requestModel.Email) || !validator.ValidateProfession(requestModel.Profession)) { responseModel.IsValid = false; return responseModel; } } UserProfileRepo userRepo = new UserProfileRepo(); bool isVerified = userRepo.AddUserByAuthenId(requestModel.Email , requestModel.Profession , requestModel.FirstName , requestModel.LastName , requestModel.PhoneNumber ,requestModel.ApplicationId); if (!isVerified) { responseModel.IsValid = false; responseModel.Error = "Account already exists."; return responseModel; } int GetUserId; if (requestModel.ApplicationId == 1) { GetUserId = userRepo.GetUserId(requestModel.PhoneNumber); } else GetUserId = userRepo.GetUserId(requestModel.Email); InstallationRepo installationRepo = new InstallationRepo(); Guid installationGuid = installationRepo.AddInstallation(GetUserId, requestModel.ApplicationId, requestModel.DeviceId); responseModel.installationGuid = installationGuid; responseModel.IsValid = true; responseModel.Error = null; return responseModel; }
/// <summary> /// Add installation if not exist and check for IsNumberExist or Account , IsNUmberVerified , IsScratchCardValid /// </summary> /// <param name="requestModel"></param> /// <returns></returns> #region Authen Number public AuthenticatePhoneNumberResponseModel AuthenNumber(AuthenticatePhoneNumberRequestModel requestModel) { AuthenticatePhoneNumberResponseModel responseModel = new AuthenticatePhoneNumberResponseModel(); UserProfileRepo userprofilerepo = new UserProfileRepo(); UserProfile UserProfile = userprofilerepo.AuthenNumber(requestModel.AuthenId); InputValidator validator = new InputValidator(); if(requestModel.ApplicationId == 1) //Check If Request From MObile Application or Desktop Application { if (!validator.ValidatePhoneNumber(requestModel.AuthenId)) { responseModel.IsValid = false; responseModel.Error = "Please provide valid Phone Number"; return responseModel; } } else { if (!validator.ValidateEmail(requestModel.AuthenId)) { responseModel.IsValid = false; responseModel.Error = "Please provide valid Phone Number"; return responseModel; } } if (UserProfile == null) { responseModel.IsNumberExist = false; responseModel.IsNumberVerified = false; responseModel.IsScratchCardValid = false; responseModel.IsValid = true; return responseModel; } //Add if not exist InstallationRepo repoclass = new InstallationRepo(); Guid getGUID = repoclass.AddInstallation(UserProfile.UserId, requestModel.ApplicationId, requestModel.DeviceId); if(!UserProfile.IsAuthenIdVerified) { responseModel.IsNumberExist = true; responseModel.IsNumberVerified = false; responseModel.IsScratchCardValid = false; responseModel.GUID = getGUID; responseModel.IsValid = true; return responseModel; } bool IsValid = UserProfile.UserApps.Any(x => x.DateSubscribed > DateTime.Now); if(!IsValid) { responseModel.IsNumberExist = true; responseModel.IsNumberVerified = true; responseModel.IsScratchCardValid = false; responseModel.GUID = getGUID; responseModel.IsValid = true; return responseModel; } responseModel.IsNumberExist = true; responseModel.IsNumberVerified = true; responseModel.IsScratchCardValid = true; responseModel.GUID = getGUID; responseModel.IsValid = true; return responseModel; }