public async Task <IActionResult> ConfSponsors(string editionId, LegacyRequestBody body) { if (!this.IsValidRequest(body)) { return(Unauthorized("Invalid client")); } var language = this.GetLanguage(); string cacheKey = $"ConfSponsors-{editionId}-{language}"; this.logger.LogInformation($"Retrieving data with key '{cacheKey}' from cache"); var cacheResult = this.cacheService.GetValue <LegacyConfSponsorsDTO>(cacheKey); if (cacheResult != null) { this.logger.LogInformation($"Retrieved from cache"); return(Ok(cacheResult)); } this.logger.LogInformation($"Not found in cache"); var edition = await this.editionsRepository.GetByLanguageAndId(language, editionId); var legacyConfSponsors = LegacyConfSponsorsUtils.ToLegacyConfSponsorsDTO(edition.Sponsors); this.cacheService.SetValue(cacheKey, legacyConfSponsors); return(Ok(legacyConfSponsors)); }
private bool IsValidRequest(LegacyRequestBody body) { if (body == null) { return(false); } var isValidUser = body.User != null && body.User.ToLower() == this.mobileAppUser.ToLower(); var isValidToken = body.Token != null && body.Token.ToLower() == this.mobileAppToken.ToLower(); return(isValidUser && isValidToken); }