/// <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; }