QrRapido/Views/Shared/_AdSpace.cshtml
Ricardo Carneiro 12afcb3d83
Some checks failed
Deploy QR Rapido / test (push) Failing after 26s
Deploy QR Rapido / build-and-push (push) Has been skipped
Deploy QR Rapido / deploy-staging (push) Has been skipped
Deploy QR Rapido / deploy-production (push) Has been skipped
fix: adsense
2025-08-11 19:20:39 -03:00

89 lines
3.2 KiB
Plaintext

@using QRRapidoApp.Services
@using Microsoft.Extensions.Localization
@model dynamic
@inject AdDisplayService AdService
@inject IStringLocalizer<QRRapidoApp.Resources.SharedResource> Localizer
@{
var userId = User?.FindFirst(System.Security.Claims.ClaimTypes.NameIdentifier)?.Value;
var showAds = await AdService.ShouldShowAds(userId);
var position = ViewBag.position ?? Model?.position ?? "header";
var tagAdSense = ViewBag.AdSenseTag;
<!-- AdSense -->
@Html.Raw(ViewBag.AdSenseScript);
}
@if (showAds)
{
@switch (position)
{
case "header":
<div class="ad-container ad-header mb-4">
<div class="ad-label">@Localizer["Advertisement"]</div>
<ins class="adsbygoogle"
style="display:inline-block;width:728px;height:90px"
data-ad-client="@tagAdSense"
data-ad-slot="QR19750801"></ins>
</div>
break;
case "sidebar":
<div class="ad-container ad-sidebar mb-4">
<div class="ad-label">@Localizer["Advertisement"]</div>
<ins class="adsbygoogle"
style="display:inline-block;width:300px;height:250px"
data-ad-client="@tagAdSense"
data-ad-slot="QR19750802"></ins>
</div>
break;
case "footer":
<div class="ad-container ad-footer mt-5 mb-4">
<div class="ad-label">@Localizer["Advertisement"]</div>
<ins class="adsbygoogle"
style="display:inline-block;width:728px;height:90px"
data-ad-client="@tagAdSense"
data-ad-slot="QR19750803"></ins>
</div>
break;
case "content":
<div class="ad-container ad-content my-4">
<div class="ad-label">@Localizer["Advertisement"]</div>
<ins class="adsbygoogle"
style="display:block"
data-ad-client="@tagAdSense"
data-ad-slot="QR19750804"
data-ad-format="auto"
data-full-width-responsive="true"></ins>
</div>
break;
}
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
}
else if (User.Identity.IsAuthenticated)
{
var isPremium = await AdService.HasValidPremiumSubscription(userId);
if (isPremium)
{
<!-- Premium User Message -->
<div class="alert alert-success ad-free-notice mb-3">
<i class="fas fa-crown text-warning"></i>
<span><strong>@Localizer["PremiumUserNoAds"]</strong></span>
</div>
}
else
{
<!-- Upgrade to Premium Message -->
<div class="alert alert-info upgrade-notice mb-3">
<i class="fas fa-star text-warning"></i>
<span><strong>@Localizer["UpgradePremiumRemoveAds"]</strong></span>
<a href="/Premium/Upgrade" class="btn btn-sm btn-warning ms-2">
<i class="fas fa-crown"></i> @Localizer["PremiumBenefitsShort"]
</a>
</div>
}
}