public AuthenticatePhoneNumberResponseModel AuthenNumber(AuthenticatePhoneNumberRequestModel requestModel)
 {
     AuthenCase authenCase = new AuthenCase();
     return authenCase.AuthenNumber(requestModel);
 }
        /// <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;
        }
        public HttpResponseMessage AuthenNumber(AuthenticatePhoneNumberRequestModel requestModel)
        {
            if (requestModel == null)
            {
                return Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Invalid request");
            }

            requestModel = new AuthenticatePhoneNumberRequestModel()
            {
                DeviceId = requestModel.DeviceId,
                AuthenId = requestModel.AuthenId,
                ApplicationId = requestModel.ApplicationId
            };


            if (!ModelState.IsValid)
            {
                return Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Invalid request");
            }

            AuthenActions authenActions = new AuthenActions();
            AuthenticatePhoneNumberResponseModel responseModel = authenActions.AuthenNumber(requestModel);

            if (responseModel.Error != null)
            {
                return Request.CreateErrorResponse(HttpStatusCode.OK, responseModel.Error);
            }

            return Request.CreateResponse(HttpStatusCode.OK, responseModel, "application/json");
        }