Convert-it/Controllers/HomeController.cs
2025-09-10 01:06:53 -03:00

128 lines
5.4 KiB
C#

using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Localization;
using System.Collections.Generic;
namespace Convert_It_Online.Controllers
{
// ViewModel para representar uma ferramenta no menu da Home
public class ToolViewModel
{
public required string TitleKey { get; set; }
public required string DescriptionKey { get; set; }
public required string Area { get; set; }
public required string Controller { get; set; }
public required string IconClass { get; set; } // Propriedade para o ícone
public string Action { get; set; } = "Index";
}
public class HomeController : Controller
{
private readonly IStringLocalizer<SharedResource> _localizer;
public HomeController(IStringLocalizer<SharedResource> localizer)
{
_localizer = localizer;
}
private void SetCommonViewBagProperties()
{
ViewBag.HomeLink = _localizer["HomeLink"];
ViewBag.TextMenuTitle = _localizer["TextMenuTitle"];
ViewBag.ImageMenuTitle = _localizer["ImageMenuTitle"];
ViewBag.CaseConverterTitle = _localizer["CaseConverterTitle"];
ViewBag.JpgToWebpTitle = _localizer["JpgToWebpTitle"];
ViewBag.FooterText = _localizer["FooterText"];
ViewBag.About = _localizer["About"];
ViewBag.Contact = _localizer["Contact"];
ViewBag.Terms = _localizer["Terms"];
}
public IActionResult Index()
{
SetCommonViewBagProperties();
ViewBag.PageTitle = _localizer["PageTitle"];
ViewBag.Subtitle = _localizer["Subtitle"];
ViewBag.ChooseConverter = _localizer["ChooseConverter"];
ViewBag.AboutSiteTitle = _localizer["AboutSiteTitle"];
ViewBag.AboutSiteContent = _localizer["AboutSiteContent"];
ViewBag.WhyFreeTitle = _localizer["WhyFreeTitle"];
ViewBag.WhyFreeContent = _localizer["WhyFreeContent"];
ViewBag.SecurityTitle = _localizer["SecurityTitle"];
ViewBag.SecurityContent = _localizer["SecurityContent"];
ViewBag.TextToolsTitle = _localizer["TextToolsTitle"];
ViewBag.TextToolsDescription = _localizer["TextToolsDescription"];
ViewBag.ImageToolsTitle = _localizer["ImageToolsTitle"];
ViewBag.ImageToolsDescription = _localizer["ImageToolsDescription"];
var availableTools = new List<ToolViewModel>
{
new ToolViewModel
{
TitleKey = "TextToolsTitle",
DescriptionKey = "TextToolsDescription",
Area = "TextTools",
Controller = "CaseConverter",
IconClass = "bi-fonts"
},
new ToolViewModel
{
TitleKey = "ImageToolsTitle",
DescriptionKey = "ImageToolsDescription",
Area = "ImageConverters",
Controller = "JpgToWebp",
IconClass = "bi-image-alt"
}
};
return View(availableTools);
}
public IActionResult About()
{
SetCommonViewBagProperties();
ViewBag.AboutTitle = _localizer["AboutTitle"];
ViewBag.WhatIsTitle = _localizer["WhatIsTitle"];
ViewBag.WhatIsContent = _localizer["WhatIsContent"];
ViewBag.MissionTitle = _localizer["MissionTitle"];
ViewBag.MissionContent = _localizer["MissionContent"];
ViewBag.FeaturesTitle = _localizer["FeaturesTitle"];
ViewBag.Feature1 = _localizer["Feature1"];
ViewBag.Feature2 = _localizer["Feature2"];
ViewBag.Feature3 = _localizer["Feature3"];
ViewBag.Feature4 = _localizer["Feature4"];
ViewBag.StartConverting = _localizer["StartConverting"];
return View();
}
public IActionResult Contact()
{
SetCommonViewBagProperties();
ViewBag.ContactTitle = _localizer["ContactTitle"];
ViewBag.ContactIntro = _localizer["ContactIntro"];
ViewBag.EmailTitle = _localizer["EmailTitle"];
ViewBag.SupportTitle = _localizer["SupportTitle"];
ViewBag.SupportTime = _localizer["SupportTime"];
ViewBag.FaqTitle = _localizer["FaqTitle"];
return View();
}
public IActionResult Terms()
{
SetCommonViewBagProperties();
ViewBag.TermsTitle = _localizer["TermsTitle"];
ViewBag.TermsIntro = _localizer["TermsIntro"];
ViewBag.AcceptanceTitle = _localizer["AcceptanceTitle"];
ViewBag.AcceptanceContent = _localizer["AcceptanceContent"];
ViewBag.ServiceTitle = _localizer["ServiceTitle"];
ViewBag.ServiceContent = _localizer["ServiceContent"];
ViewBag.PrivacyTitle = _localizer["PrivacyTitle"];
ViewBag.PrivacyContent = _localizer["PrivacyContent"];
ViewBag.LimitationTitle = _localizer["LimitationTitle"];
ViewBag.LimitationContent = _localizer["LimitationContent"];
ViewBag.ChangesTitle = _localizer["ChangesTitle"];
ViewBag.ChangesContent = _localizer["ChangesContent"];
ViewBag.LastUpdated = _localizer["LastUpdated"];
ViewBag.BackToHome = _localizer["BackToHome"];
return View();
}
}
}