/// <summary>
        /// Check for Scratch Card Validation Weather Card Exist or Used by Other or Used by same or User Exist
        /// </summary>
        /// <param name="requestModel"></param>
        /// <returns></returns>
        public CardValidationResponseModel ScratchCardValidation(ScratchCardRequestModel requestModel)
        {
            CardValidationResponseModel responseModel = new CardValidationResponseModel();

            #region GetUserID
            InstallationRepo installationRepo = new InstallationRepo();
            int? userId = installationRepo.ValidateInstallation(requestModel.InstallationGuid, requestModel.DeviceIdentifier,requestModel.ApplicationId);

            if (userId == null)
            {
                responseModel.IsValid = false;
                responseModel.Error = "User not exist";     
                return responseModel;
            }
            #endregion

            #region CardExist
            ScratchCardRepo scratchCardRepo = new ScratchCardRepo();
            bool IsExist = scratchCardRepo.ScratchCardExist(requestModel.CardNumber, requestModel.ApplicationId);
            if (!IsExist)
            {
                responseModel.IsValid = false;
                responseModel.Error = "Invalid Scratch card No";
                return responseModel;
            }
            #endregion

            #region CardUsed
            EnumTypes.ScratchCardUsed CardUsageEnum = scratchCardRepo.ScratchCardUsed(userId.Value, requestModel.CardNumber);  
            if (CardUsageEnum == EnumTypes.ScratchCardUsed.UsedBySame)
            {
                responseModel.IsValid = false;
                responseModel.Error = "Used by Same";
                return responseModel;
            }
            else if(CardUsageEnum== EnumTypes.ScratchCardUsed.UsedByOther)
            {
                responseModel.IsValid = false;
                responseModel.Error = "Used By Other";
                return responseModel;
            }
            #endregion

            #region RemoveFreeData
            DestroyFreeDataRepo freeDataRepo = new DestroyFreeDataRepo();
            freeDataRepo.DeleteFreeData(userId.Value); 
            #endregion

            #region CardType
            bool IsComplementary = scratchCardRepo.ScratchCardComplementary(requestModel.CardNumber);
            #endregion

            responseModel.IsValid = true;
            responseModel.Error = null;
            responseModel.IsComplimentary = IsComplementary;
            responseModel.UserId = userId.Value;
            return responseModel;
        }
        /// <summary>
        /// Disable Installation if Mobile Verification Fails
        /// </summary>
        /// <param name="guid"></param>
        /// <returns></returns>
        public BaseResponseModel DisableInstallation(Guid guid)
        {
            BaseResponseModel responseModel = new BaseResponseModel();
            InstallationRepo repoclass = new InstallationRepo();
            string Error =  repoclass.DisableInstallation(guid);

            if(Error != null)
            {
                responseModel.IsValid = false;
                responseModel.Error = Error;
                return responseModel;
            }

            responseModel.Error = Error;
            responseModel.IsValid = true;
            return responseModel;
        }
Exemplo n.º 3
0
        public IsUpdateAvailableResponseModel IsUpdateAvailable(IsUpdateAvailableRequestModel requestmodel)
        {
            IsUpdateAvailableResponseModel responseModel = new IsUpdateAvailableResponseModel();

            InstallationRepo installationrepo = new InstallationRepo();
            bool IsEnable = installationrepo.IsInstallationEnable(requestmodel.InstallationGuid);

            if(!IsEnable)
            {
                responseModel.IsValid = true;
                responseModel.IsInstallationValid = false;
                responseModel.IsUpdateAvailable = false;
                responseModel.Error = null;
                return responseModel;
            }

            UpdateRepo updaterepo = new UpdateRepo();
            EnumTypes.UpdateAvailable isChecker = updaterepo.checkForUpdate(requestmodel.InstallationGuid, requestmodel.LastDateModified);

            if(isChecker == EnumTypes.UpdateAvailable.UpdateNotAvailable)
            {
                responseModel.IsInstallationValid = true;
                responseModel.IsValid = true;
                responseModel.IsUpdateAvailable = false;
                responseModel.Error = null;
                return responseModel;
            }

            if(isChecker == EnumTypes.UpdateAvailable.UpdateAvailable)
            {
                responseModel.IsInstallationValid = true;
                responseModel.IsValid = true;
                responseModel.IsUpdateAvailable = true;
                responseModel.Error = null;
                return responseModel;
            }

            responseModel.IsInstallationValid = true;
            responseModel.IsValid = false;
            responseModel.IsUpdateAvailable = false;
            responseModel.Error = "Installation Not Exist";
            return responseModel;
        }
Exemplo n.º 4
0
        /// <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;
        }
Exemplo n.º 5
0
        /// <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;
        }