Add [Route] and [HttpGet] attributes to ensure proper route discovery and matching for anonymous ShareCard access. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
70 lines
2.0 KiB
C#
70 lines
2.0 KiB
C#
using System;
|
|
using System.Threading.Tasks;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using LittleShop.Services;
|
|
|
|
namespace LittleShop.Areas.Admin.Controllers;
|
|
|
|
/// <summary>
|
|
/// Public-facing bot pages that don't require authentication.
|
|
/// These are separated from the main BotsController to avoid authorization conflicts.
|
|
/// </summary>
|
|
[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<IActionResult> 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<IActionResult> 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);
|
|
}
|
|
}
|