public HttpResponseMessage SubscribedScratchCard(ScratchCardRequestModel requestModel) { if (requestModel == null) { return Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Invalid Request"); } requestModel = new ScratchCardRequestModel { DeviceIdentifier = requestModel.DeviceIdentifier, InstallationGuid = requestModel.InstallationGuid, CardNumber = requestModel.CardNumber, ApplicationId = requestModel.ApplicationId //DeviceIdentifier = "Hammads", //InstallationGuid = Guid.Parse("a56d189c-8daf-4708-b84d-a1f4d2ff377b"), //CardNumber = "23123456789012", //ApplicationId = 1 }; if (!ModelState.IsValid) { return Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Invalid Request"); } DataActions dataActions = new DataActions(); ScratchCardResponseModel responseModel = dataActions.SubscribedScratchCard(requestModel); if (responseModel.Error != null) { return Request.CreateResponse(HttpStatusCode.OK, responseModel); } return Request.CreateResponse(HttpStatusCode.OK, responseModel, "application/json"); }
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; }
/// <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> /// 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; }
public ScratchCardResponseModel SubscribedScratchCard(ScratchCardRequestModel requestModel) { DataCase dataActions = new DataCase(); return dataActions.SubscribedScratchCard(requestModel); }