public ValidateScratchCardResponseModel validatescratchcard(ValidateScratchCardRequestModel initialModel)
        {
            ValidateScratchCardResponseModel responseModel = new ValidateScratchCardResponseModel();

            ScratchCardRequestModel requestModel = new ScratchCardRequestModel
            {
                CardNumber = initialModel.CardNumber,
                InstallationGuid = initialModel.InstallationGuid,
                ApplicationId = initialModel.ApplicationId,
                DeviceIdentifier = initialModel.DeviceIdentifier
            };

            CardValidation cardValidator = new CardValidation();
            CardValidationResponseModel cardValidationResponseModel = cardValidator.ScratchCardValidation(requestModel);

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

            responseModel.Error = null;
            responseModel.IsValid = true;
            responseModel.IsComplimentary = cardValidationResponseModel.IsComplimentary;
            return responseModel;
        }
示例#2
0
        /// <summary>
        /// Add to ScratchCard and UserDatset
        /// </summary>
        /// <param name="requestModel"></param>
        /// <returns></returns>
        #region SubscribedScratchCard
        public ScratchCardResponseModel SubscribedScratchCard(ScratchCardRequestModel requestModel)
        {
            ScratchCardResponseModel responseModel = new ScratchCardResponseModel();

            #region CardValidation
            CardValidation cardValidator = new CardValidation();
            CardValidationResponseModel cardValidationResponseModel = cardValidator.ScratchCardValidation(requestModel);

            ////IsComplimentary false and IsValid true
            //if (!cardValidationResponseModel.IsComplimentary && cardValidationResponseModel.IsValid)
            //{
            //    MobileVerification mobileVerifier = new MobileVerification();
            //    bool IsVerified = mobileVerifier.NumberVerifier(cardValidationResponseModel.UserId);

            //    if (!IsVerified)
            //    {
            //        responseModel.IsValid = false;
            //        responseModel.Error = "Number not Verified";
            //        return responseModel;
            //    }
            //}

            //IsValid false
            if (!cardValidationResponseModel.IsValid)
            {
                responseModel.IsValid = false;
                responseModel.Error = cardValidationResponseModel.Error;
                return responseModel;
            }
            #endregion

            #region AddToScratchCard
            ScratchCardRepo scratchCardRepo = new ScratchCardRepo();
            ScratchCard scratchCard = scratchCardRepo.AddToScratchCard(requestModel.CardNumber, cardValidationResponseModel.UserId, requestModel.ApplicationId);
            #endregion

            #region AddToUserDataSet
            UserDataSetRepo userDataSetRepo = new UserDataSetRepo();
            userDataSetRepo.AddUserDataSet(scratchCard.UserId, scratchCard.DataSetId, scratchCard.ValidityPeriod, scratchCard.DateUsed);
            #endregion

            responseModel.IsValid = true;
            responseModel.Error = null;
            return responseModel;
        }