diff --git a/LittleShop/Areas/Admin/Controllers/PublicBotsController.cs b/LittleShop/Areas/Admin/Controllers/PublicBotsController.cs new file mode 100644 index 0000000..e774ae4 --- /dev/null +++ b/LittleShop/Areas/Admin/Controllers/PublicBotsController.cs @@ -0,0 +1,66 @@ +using System; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using LittleShop.Services; + +namespace LittleShop.Areas.Admin.Controllers; + +/// +/// Public-facing bot pages that don't require authentication. +/// These are separated from the main BotsController to avoid authorization conflicts. +/// +[Area("Admin")] +[AllowAnonymous] +public class PublicBotsController : Controller +{ + private readonly IBotService _botService; + + public PublicBotsController(IBotService botService) + { + _botService = botService; + } + + // GET: Admin/PublicBots/ShareCard/5 + public async Task ShareCard(Guid id) + { + var bot = await _botService.GetBotByIdAsync(id); + if (bot == null) + return NotFound(); + + // Build the tg.me link + var telegramLink = !string.IsNullOrEmpty(bot.PlatformUsername) + ? $"https://t.me/{bot.PlatformUsername}" + : null; + + ViewData["TelegramLink"] = telegramLink; + + // Get review stats (TODO: Replace with actual review data from database) + // For now using sample data - in production, query from Reviews table + ViewData["ReviewCount"] = 127; + ViewData["AverageRating"] = 4.8m; + + return View("~/Areas/Admin/Views/Bots/ShareCard.cshtml", bot); + } + + // GET: Admin/PublicBots/ShareCardEmbed/5 + public async Task ShareCardEmbed(Guid id) + { + var bot = await _botService.GetBotByIdAsync(id); + if (bot == null) + return NotFound(); + + // Build the tg.me link + var telegramLink = !string.IsNullOrEmpty(bot.PlatformUsername) + ? $"https://t.me/{bot.PlatformUsername}" + : null; + + ViewData["TelegramLink"] = telegramLink; + + // Get review stats + ViewData["ReviewCount"] = 127; + ViewData["AverageRating"] = 4.8m; + + return View("~/Areas/Admin/Views/Bots/ShareCardEmbed.cshtml", bot); + } +} diff --git a/LittleShop/Areas/Admin/Views/Bots/ShareCard.cshtml b/LittleShop/Areas/Admin/Views/Bots/ShareCard.cshtml index 4eed644..77b9a4f 100644 --- a/LittleShop/Areas/Admin/Views/Bots/ShareCard.cshtml +++ b/LittleShop/Areas/Admin/Views/Bots/ShareCard.cshtml @@ -446,7 +446,7 @@ Back to Details - + View Public Card @@ -466,14 +466,14 @@ Copy this code to embed the share card on your website: IFrame Embed - <iframe src="@Url.Action("ShareCardEmbed", "Bots", new { area = "Admin", id = Model.Id }, Context.Request.Scheme)" width="450" height="750" frameborder="0" style="border-radius: 20px; overflow: hidden;"></iframe> + <iframe src="@Url.Action("ShareCardEmbed", "PublicBots", new { area = "Admin", id = Model.Id }, Context.Request.Scheme)" width="450" height="750" frameborder="0" style="border-radius: 20px; overflow: hidden;"></iframe> Copy Code Direct Link - + Copy Link
Copy this code to embed the share card on your website: