using Microsoft.AspNetCore.Mvc; using SkyArtShop.Models; using SkyArtShop.Services; namespace SkyArtShop.Controllers { [Route("diagnostics")] public class DiagnosticsController : Controller { private readonly MongoDBService _mongoService; public DiagnosticsController(MongoDBService mongoService) { _mongoService = mongoService; } [HttpGet("products")] public async Task Products() { var products = await _mongoService.GetAllAsync("Products"); var report = products.Select(p => new { p.Id, p.Name, p.ImageUrl, ImagesCount = p.Images?.Count ?? 0, FirstImage = p.Images?.FirstOrDefault(), HasImageUrl = !string.IsNullOrEmpty(p.ImageUrl), HasImages = p.Images != null && p.Images.Any() }).ToList(); return Json(report); } } }