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]
[Route("Admin/[controller]/[action]/{id?}")]
public class PublicBotsController : Controller
{
private readonly IBotService _botService;
public PublicBotsController(IBotService botService)
{
_botService = botService;
}
// GET: Admin/PublicBots/ShareCard/{id}
[HttpGet]
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/{id}
[HttpGet]
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);
}
}