using System.Diagnostics; using System.Text; using Microsoft.AspNetCore.Mvc; using CarneiroTech.Models; using CarneiroTech.Services; namespace CarneiroTech.Controllers; public class HomeController : Controller { private readonly ILogger _logger; private readonly ICaseService _caseService; public HomeController(ILogger logger, ICaseService caseService) { _logger = logger; _caseService = caseService; } public async Task Index() { var featuredCases = await _caseService.GetFeaturedCasesAsync(); ViewData["Title"] = "Carneiro Tech - Solution Design & Technical Consulting"; ViewData["Description"] = "20+ years connecting business and technology. Specialized in technical proposals, MVP definition, and due diligence."; ViewData["Keywords"] = "solution design, technical consulting, SAP integration, enterprise architecture, MVP definition, due diligence"; return View(featuredCases); } public IActionResult Privacy() { ViewData["Title"] = "Privacy Policy - Carneiro Tech"; return View(); } [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] public IActionResult Error() { return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier }); } [Route("sitemap.xml")] public async Task Sitemap() { var cases = await _caseService.GetAllCasesAsync(); var sitemap = new StringBuilder(); sitemap.AppendLine(""); sitemap.AppendLine(""); // Homepage sitemap.AppendLine($@" https://carneirotech.com/ {DateTime.UtcNow:yyyy-MM-dd} weekly 1.0 "); // Cases index sitemap.AppendLine($@" https://carneirotech.com/cases {DateTime.UtcNow:yyyy-MM-dd} weekly 0.9 "); // Each case foreach (var c in cases) { var lastMod = c.Metadata.Date != DateTime.MinValue ? c.Metadata.Date : DateTime.UtcNow; sitemap.AppendLine($@" https://carneirotech.com/cases/{c.Metadata.Slug} {lastMod:yyyy-MM-dd} monthly 0.8 "); } sitemap.AppendLine(""); return Content(sitemap.ToString(), "application/xml"); } [HttpPost] public IActionResult Contact(ContactFormModel model) { if (!ModelState.IsValid) { TempData["Error"] = "Por favor, preencha todos os campos corretamente."; return RedirectToAction("Index", new { fragment = "contact" }); } // TODO: Implement email sending logic here (SendGrid, SMTP, etc.) _logger.LogInformation($"Contact form submitted: {model.Name} - {model.Email}"); TempData["Success"] = "Mensagem enviada com sucesso! Retornaremos em breve."; return RedirectToAction("Index", new { fragment = "contact" }); } }