public HttpResponseMessage SendLackCreditReport(HttpRequestMessage request, [FromBody] StoreAttributes data) { PersonBL ConsumerAuth = new PersonBL(); GenericApiResponse response = new GenericApiResponse(); StoreBL storeBL = new StoreBL(); string error = ""; SimpleTextResponse ReportResponse = new SimpleTextResponse(); try { IEnumerable <string> key = null; request.Headers.TryGetValues("authenticationKey", out key); var consumerFb = ConsumerAuth.authenticateConsumer(key.FirstOrDefault().ToString()); if (consumerFb != null) { if (!string.IsNullOrEmpty(data.FirebaseID)) { int?ResultOfReport = storeBL.AirTimeReporting(data.StoreName, data.AddressStore, data.Longitude, data.Latitude, data.FirebaseID, consumerFb.ConsumerID, consumerFb.RegistrationDate, consumerFb.ModificationDate, ref error); if (ResultOfReport > 0) { ReportResponse.Message = "Operation completed succesfully"; ReportResponse.result = true; return(Request.CreateResponse <IResponse>(HttpStatusCode.OK, ReportResponse)); } else { ReportResponse.Message = "Something went wrong"; ReportResponse.result = false; return(Request.CreateResponse <IResponse>(HttpStatusCode.InternalServerError, ReportResponse)); } } else { ReportResponse.Message = "Bad Request"; ReportResponse.result = false; return(Request.CreateResponse <IResponse>(HttpStatusCode.BadRequest, ReportResponse)); } } else { response.HttpCode = 404; response.Message = "Facebook information not found"; return(Request.CreateResponse <IResponse>(HttpStatusCode.BadRequest, response)); } } catch (Exception ex) { response.HttpCode = 500; response.Message = "something went wrong"; return(Request.CreateResponse <IResponse>(HttpStatusCode.InternalServerError, response)); } }
public HttpResponseMessage Post(HttpRequestMessage request) { PersonBL ConsumerAuth = new PersonBL(); GenericApiResponse response = new GenericApiResponse(); GameBL gameBL = new GameBL(); string error = ""; try { IEnumerable <string> AppVersion = null; request.Headers.TryGetValues("AppVersion", out AppVersion); IEnumerable <string> Platform = null; request.Headers.TryGetValues("Platform", out Platform); bool ApplyValidation = bool.Parse(ConfigurationManager.AppSettings["ApplyValidationAppVersion"].ToString()); if (ApplyValidation == false || (AppVersion != null && Platform != null)) { string versionRequired = ""; var isValidVersion = (ApplyValidation == false) ? true : gameBL.IsValidAppVersion(AppVersion.FirstOrDefault(), Platform.FirstOrDefault(), ref error, ref versionRequired); if (isValidVersion) { IEnumerable <string> key = null; request.Headers.TryGetValues("authenticationKey", out key); var consumerFb = ConsumerAuth.authenticateConsumer(key.FirstOrDefault().ToString()); if (consumerFb != null) { var process = gameBL.ProcessToValidateAndWinPrize(consumerFb.ConsumerID, consumerFb.CountryID, ref error); if (error == "" && (process.ResponseCode == "00" || process.ResponseCode == "02")) { WinPrizeInteractor interactor = new WinPrizeInteractor(); var responseSuccess = interactor.createWinPrizeResultsResponse(process, error); return(Request.CreateResponse <IResponse>(HttpStatusCode.OK, responseSuccess)); } else { response.HttpCode = 500; response.Message = "something went wrong"; return(Request.CreateResponse <IResponse>(HttpStatusCode.InternalServerError, response)); } } else { response.HttpCode = 404; response.Message = "Facebook information not found"; return(Request.CreateResponse <IResponse>(HttpStatusCode.BadRequest, response)); } } else { response.HttpCode = 426; response.InternalCode = versionRequired; response.Message = "Upgrade required"; return(Request.CreateResponse <IResponse>(HttpStatusCode.UpgradeRequired, response)); } } else { response.HttpCode = 404; response.Message = "Version or Platform parameter can not be null"; return(Request.CreateResponse <IResponse>(HttpStatusCode.BadRequest, response)); } } catch (Exception en) { response.HttpCode = 500; response.Message = "something went wrong"; return(Request.CreateResponse <IResponse>(HttpStatusCode.InternalServerError, response)); } }
public HttpResponseMessage ActivatePrize(HttpRequestMessage request, [FromBody] ActivatePrizeRequest data) { PersonBL ConsumerAuth = new PersonBL(); GenericApiResponse response = new GenericApiResponse(); GameBL gameBL = new GameBL(); string error = ""; try { IEnumerable <string> AppVersion = null; request.Headers.TryGetValues("AppVersion", out AppVersion); IEnumerable <string> Platform = null; request.Headers.TryGetValues("Platform", out Platform); bool ApplyValidation = bool.Parse(ConfigurationManager.AppSettings["ApplyValidationAppVersion"].ToString()); if (ApplyValidation == false || (AppVersion != null && Platform != null)) { string versionRequired = ""; var isValidVersion = (ApplyValidation == false) ? true : gameBL.IsValidAppVersion(AppVersion.FirstOrDefault(), Platform.FirstOrDefault(), ref error, ref versionRequired); if (isValidVersion) { if (String.IsNullOrEmpty(data.Phone) || String.IsNullOrEmpty(data.PIN)) { string errorMessage = (String.IsNullOrEmpty(data.Phone)) ? "Phone can not be empty" : "PIN can not be empty"; response.HttpCode = 404; response.Message = errorMessage; return(Request.CreateResponse <IResponse>(HttpStatusCode.BadRequest, response)); } else { IEnumerable <string> key = null; request.Headers.TryGetValues("authenticationKey", out key); var consumerFb = ConsumerAuth.authenticateConsumer(key.FirstOrDefault().ToString()); if (consumerFb != null) { ActivatePrizeInteractor interactor = new ActivatePrizeInteractor(); var responseSuccess = interactor.SuccessActivatePrizeResponse(consumerFb.ConsumerID, data.Phone, data.PIN, ref error); return(Request.CreateResponse <IResponse>(HttpStatusCode.OK, responseSuccess)); } else { response.HttpCode = 404; response.Message = "Facebook information not found"; return(Request.CreateResponse <IResponse>(HttpStatusCode.BadRequest, response)); } } } else { response.HttpCode = 426; response.InternalCode = versionRequired; response.Message = "Upgrade required"; return(Request.CreateResponse <IResponse>(HttpStatusCode.UpgradeRequired, response)); } } else { response.HttpCode = 404; response.Message = "Version or Platform parameter can not be null"; return(Request.CreateResponse <IResponse>(HttpStatusCode.BadRequest, response)); } } catch (Exception en) { response.HttpCode = 500; response.Message = "something went wrong"; return(Request.CreateResponse <IResponse>(HttpStatusCode.InternalServerError, response)); } }
public HttpResponseMessage Post(HttpRequestMessage request, [FromBody] ExchangeDataRequest data) { int type = 0; GenericApiResponse response = new GenericApiResponse(); GameBL gameBL = new GameBL(); PersonBL ConsumerAuth = new PersonBL(); ExchangeCoinsBL exchangeBL = new ExchangeCoinsBL(); int coins = 0; string error = ""; string code = ""; Random random = new Random(); try { IEnumerable <string> AppVersion = null; request.Headers.TryGetValues("AppVersion", out AppVersion); IEnumerable <string> Platform = null; request.Headers.TryGetValues("Platform", out Platform); bool ApplyValidation = bool.Parse(ConfigurationManager.AppSettings["ApplyValidationAppVersion"].ToString()); if (ApplyValidation == false || (AppVersion != null && Platform != null)) { string versionRequired = ""; var isValidVersion = (ApplyValidation == false) ? true : gameBL.IsValidAppVersion(AppVersion.FirstOrDefault(), Platform.FirstOrDefault(), ref error, ref versionRequired); if (isValidVersion) { if (string.IsNullOrEmpty(data.LocationID) && (data.ChestType == 0 || data.ChestType == 0)) { response.HttpCode = 400; response.Message = "LocationID or ChestType cannot be empty"; return(Request.CreateResponse <IResponse>(HttpStatusCode.BadRequest, response)); } else { IEnumerable <string> key = null; request.Headers.TryGetValues("authenticationKey", out key); var consumerFb = ConsumerAuth.authenticateConsumer(key.FirstOrDefault().ToString()); if (consumerFb != null) { string RandomCoinsOrSouvenir = ConfigurationManager.AppSettings["RandomCoinOrSouvenir"].ToString(); var range = RandomCoinsOrSouvenir.Split(','); int minValue = int.Parse(range[0]); int maxValue = int.Parse(range[1]); int RandomResult = random.Next(minValue, maxValue); if (RandomResult <= 9) { type = 1; } else { type = 2; } if (type == 1) { var result = exchangeBL.ProcessExchangeCoins(data.LocationID, data.Longitude, data.Latitude, data.ChestType, consumerFb.ConsumerID, ref coins, data.AgeID); if (error == "") { ExchangeCoinsInteractor interactor = new ExchangeCoinsInteractor(); var responseSuccess = interactor.createExchangeCoinsResultsResponse(result, coins); return(Request.CreateResponse <IResponse>(HttpStatusCode.OK, responseSuccess)); } else { response.HttpCode = 500; response.Message = "something went wrong"; return(Request.CreateResponse <IResponse>(HttpStatusCode.InternalServerError, response)); } } else { var result = exchangeBL.ProcessExchangeSouvenir(data.LocationID, data.Longitude, data.Latitude, data.ChestType, consumerFb.ConsumerID, ref error, data.AgeID); ExchangeCoinsInteractor interactor = new ExchangeCoinsInteractor(); var responseSuccess = interactor.createExchangeSouvewnorResultsResponse(result, error); return(Request.CreateResponse <IResponse>(HttpStatusCode.OK, responseSuccess)); } } else { response.HttpCode = 404; response.Message = "Facebook information not found"; return(Request.CreateResponse <IResponse>(HttpStatusCode.BadRequest, response)); } } } else { response.HttpCode = 426; response.InternalCode = versionRequired; response.Message = "Upgrade required"; return(Request.CreateResponse <IResponse>(HttpStatusCode.UpgradeRequired, response)); } } else { response.HttpCode = 404; response.Message = "Version or Platform parameter can not be null"; return(Request.CreateResponse <IResponse>(HttpStatusCode.BadRequest, response)); } } catch (Exception) { response.HttpCode = 500; response.Message = "something went wrong"; return(Request.CreateResponse <IResponse>(HttpStatusCode.InternalServerError, response)); } }
public HttpResponseMessage GetStoreItems(HttpRequestMessage request) { string error = ""; PersonBL ConsumerAuth = new PersonBL(); GameStoreResponse storeResponse = new GameStoreResponse(); GameStoreInteractor storeInteractor = new GameStoreInteractor(); GenericApiResponse response = new GenericApiResponse(); StoreBL storeBL = new StoreBL(); try { IEnumerable <string> AppVersion = null; request.Headers.TryGetValues("AppVersion", out AppVersion); IEnumerable <string> Platform = null; request.Headers.TryGetValues("Platform", out Platform); bool ApplyValidation = bool.Parse(ConfigurationManager.AppSettings["ApplyValidationAppVersion"].ToString()); if (ApplyValidation == false || (AppVersion != null && Platform != null)) { string versionRequired = ""; var isValidVersion = (ApplyValidation == false) ? true : gameBL.IsValidAppVersion(AppVersion.FirstOrDefault(), Platform.FirstOrDefault(), ref error, ref versionRequired); if (isValidVersion) { IEnumerable <string> key = null; request.Headers.TryGetValues("authenticationKey", out key); var consumerFb = ConsumerAuth.authenticateConsumer(key.FirstOrDefault().ToString()); if (consumerFb != null) { var storeItems = storeBL.GetStoreItems(consumerFb.ConsumerID); if (storeItems != null) { storeInteractor.listGameStoreResponse = storeInteractor.createStoreItemsResponse(storeItems); return(Request.CreateResponse <IResponse>(HttpStatusCode.OK, storeInteractor)); } else { response.HttpCode = 400; response.Message = "invalid parameters"; return(Request.CreateResponse <IResponse>(HttpStatusCode.InternalServerError, response)); } } else { response.HttpCode = 404; response.Message = "Facebook information not found"; return(Request.CreateResponse <IResponse>(HttpStatusCode.BadRequest, response)); } } else { response.HttpCode = 426; response.InternalCode = versionRequired; response.Message = "Upgrade required"; return(Request.CreateResponse <IResponse>(HttpStatusCode.UpgradeRequired, response)); } } else { response.HttpCode = 404; response.Message = "Version or Platform parameter can not be null"; return(Request.CreateResponse <IResponse>(HttpStatusCode.BadRequest, response)); } } catch (Exception) { response.HttpCode = 500; response.Message = "something went wrong"; return(Request.CreateResponse <IResponse>(HttpStatusCode.InternalServerError, response)); } }
public HttpResponseMessage GetAges(HttpRequestMessage request) { IEnumerable <string> AppVersion = null; request.Headers.TryGetValues("AppVersion", out AppVersion); IEnumerable <string> Platform = null; request.Headers.TryGetValues("Platform", out Platform); bool ApplyValidation = bool.Parse(ConfigurationManager.AppSettings["ApplyValidationAppVersion"].ToString()); if (ApplyValidation == false || (AppVersion != null && Platform != null)) { string versionRequired = ""; var isValidVersion = (ApplyValidation == false) ? true : gameBL.IsValidAppVersion(AppVersion.FirstOrDefault(), Platform.FirstOrDefault(), ref error, ref versionRequired); if (isValidVersion) { IEnumerable <string> key = null; request.Headers.TryGetValues("authenticationKey", out key); var consumerFb = ConsumerAuth.authenticateConsumer(key.FirstOrDefault().ToString()); if (key != null) { List <AgeEN> theAgesList = ageBL.GetAges(ref error); if (theAgesList != null) { AgeResponse ageResponse = interactor.CreateAgeResponse(theAgesList); return(Request.CreateResponse <IResponse>(HttpStatusCode.OK, ageResponse)); } else { response.HttpCode = 500; response.Message = "Something went wrong"; return(Request.CreateResponse <IResponse>(HttpStatusCode.InternalServerError, response)); } } else { response.HttpCode = 400; response.Message = "Authorization token must be provided"; return(Request.CreateResponse <IResponse>(HttpStatusCode.BadRequest, response)); } } else { response.HttpCode = 426; response.InternalCode = versionRequired; response.Message = "Upgrade required"; return(Request.CreateResponse <IResponse>(HttpStatusCode.UpgradeRequired, response)); } } else { response.HttpCode = 404; response.Message = "Version or Platform parameter can not be null"; return(Request.CreateResponse <IResponse>(HttpStatusCode.BadRequest, response)); } }
public HttpResponseMessage Get(HttpRequestMessage request) { string error = ""; PersonBL ConsumerAuth = new PersonBL(); TrackingResponse responseApi = new TrackingResponse(); GenericApiResponse response = new GenericApiResponse(); IEnumerable <string> AppVersion = null; request.Headers.TryGetValues("AppVersion", out AppVersion); IEnumerable <string> Platform = null; request.Headers.TryGetValues("Platform", out Platform); bool ApplyValidation = bool.Parse(ConfigurationManager.AppSettings["ApplyValidationAppVersion"].ToString()); if (ApplyValidation == false || (AppVersion != null && Platform != null)) { string versionRequired = ""; var isValidVersion = (ApplyValidation == false) ? true : gameBL.IsValidAppVersion(AppVersion.FirstOrDefault(), Platform.FirstOrDefault(), ref error, ref versionRequired); if (isValidVersion) { IEnumerable <string> key = null; request.Headers.TryGetValues("authenticationKey", out key); var consumerFb = ConsumerAuth.authenticateConsumer(key.FirstOrDefault().ToString()); if (consumerFb != null) { var tracking = gameBL.GetProgressGame(consumerFb.ConsumerID, ref error); if (tracking != null) { responseApi.TotalWinCoins = tracking.TotalWinCoins; responseApi.TotalWinPrizes = tracking.TotalWinPrizes; responseApi.CurrentCoinsProgress = tracking.CurrentCoinsProgress; responseApi.TotalSouvenirs = tracking.TotalSouvenirs; responseApi.AgeID = tracking.AgeID; responseApi.Nickname = tracking.Nickname; return(Request.CreateResponse <IResponse>(HttpStatusCode.OK, responseApi)); } else { if (error == "") { return(Request.CreateResponse <IResponse>(HttpStatusCode.OK, responseApi)); } else { response.HttpCode = 500; response.Message = "something went wrong"; return(Request.CreateResponse <IResponse>(HttpStatusCode.InternalServerError, response)); } } } else { response.HttpCode = 404; response.Message = "Facebook information not found"; return(Request.CreateResponse <IResponse>(HttpStatusCode.BadRequest, response)); } } else { response.HttpCode = 426; response.InternalCode = versionRequired; response.Message = "Upgrade required"; return(Request.CreateResponse <IResponse>(HttpStatusCode.UpgradeRequired, response)); } } else { response.HttpCode = 404; response.Message = "Version or Platform parameter can not be null"; return(Request.CreateResponse <IResponse>(HttpStatusCode.BadRequest, response)); } }
public HttpResponseMessage Post(HttpRequestMessage request, [FromBody] PurchaseRequest data) { int type = 0; GenericApiResponse response = new GenericApiResponse(); GameBL gameBL = new GameBL(); PersonBL ConsumerAuth = new PersonBL(); int coins = 0; string error = ""; string code = ""; Random random = new Random(); try { IEnumerable <string> AppVersion = null; request.Headers.TryGetValues("AppVersion", out AppVersion); IEnumerable <string> Platform = null; request.Headers.TryGetValues("Platform", out Platform); bool ApplyValidation = bool.Parse(ConfigurationManager.AppSettings["ApplyValidationAppVersion"].ToString()); if (ApplyValidation == false || (AppVersion != null && Platform != null)) { string versionRequired = ""; var isValidVersion = (ApplyValidation == false) ? true : gameBL.IsValidAppVersion(AppVersion.FirstOrDefault(), Platform.FirstOrDefault(), ref error, ref versionRequired); if (isValidVersion) { if (data.StoreId == 0 || data.StoreId == null) { response.HttpCode = 400; response.Message = "StoreId cannot be empty"; return(Request.CreateResponse <IResponse>(HttpStatusCode.BadRequest, response)); } else { IEnumerable <string> key = null; request.Headers.TryGetValues("authenticationKey", out key); var consumerFb = ConsumerAuth.authenticateConsumer(key.FirstOrDefault().ToString()); if (consumerFb != null) { var result = gameBL.PurchaseAndGetSouvenir(consumerFb.ConsumerID, data.StoreId, ref error); if (result != null && error == "") { ShopPurchaseInteractor interactor = new ShopPurchaseInteractor(); var responseSuccess = interactor.createPurchaseResponse(result, error); return(Request.CreateResponse <IResponse>(HttpStatusCode.OK, responseSuccess)); } else { response.HttpCode = 500; response.Message = "something went wrong"; return(Request.CreateResponse <IResponse>(HttpStatusCode.InternalServerError, response)); } } else { response.HttpCode = 404; response.Message = "Facebook information not found"; return(Request.CreateResponse <IResponse>(HttpStatusCode.BadRequest, response)); } } } else { response.HttpCode = 426; response.InternalCode = versionRequired; response.Message = "Upgrade required"; return(Request.CreateResponse <IResponse>(HttpStatusCode.UpgradeRequired, response)); } } else { response.HttpCode = 404; response.Message = "Version or Platform parameter can not be null"; return(Request.CreateResponse <IResponse>(HttpStatusCode.BadRequest, response)); } } catch (Exception) { response.HttpCode = 500; response.Message = "something went wrong"; return(Request.CreateResponse <IResponse>(HttpStatusCode.InternalServerError, response)); } }