Do not send text from news controller.

This commit is contained in:
2025-11-14 15:17:50 +00:00
parent 1053617622
commit 2bb07845e1

View File

@@ -34,13 +34,12 @@ using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Localization;
namespace Marechai.Server.Controllers; namespace Marechai.Server.Controllers;
[Route("/news")] [Route("/news")]
[ApiController] [ApiController]
public class NewsController(MarechaiContext context, IStringLocalizer<NewsController> localizer) : ControllerBase public class NewsController(MarechaiContext context) : ControllerBase
{ {
[HttpGet] [HttpGet]
[AllowAnonymous] [AllowAnonymous]
@@ -86,73 +85,28 @@ public class NewsController(MarechaiContext context, IStringLocalizer<NewsContro
switch(@new.Type) switch(@new.Type)
{ {
case NewsType.NewComputerInDb: case NewsType.NewComputerInDb:
news.Add(new NewsDto(@new.AddedId,
localizer["New computer in database"],
@new.Date,
"computers",
$"{machine.Company.Name} {machine.Name}"));
break;
case NewsType.NewConsoleInDb: case NewsType.NewConsoleInDb:
news.Add(new NewsDto(@new.AddedId,
localizer["New console in database"],
@new.Date,
"consoles",
$"{machine.Company.Name} {machine.Name}"));
break;
case NewsType.NewComputerInCollection: case NewsType.NewComputerInCollection:
news.Add(new NewsDto(@new.AddedId,
localizer["New computer in collection"],
@new.Date,
"computers",
$"{machine.Company.Name} {machine.Name}"));
break;
case NewsType.NewConsoleInCollection: case NewsType.NewConsoleInCollection:
news.Add(new NewsDto(@new.AddedId,
localizer["New console in collection"],
@new.Date,
"consoles",
$"{machine.Company.Name} {machine.Name}"));
break;
case NewsType.UpdatedComputerInDb: case NewsType.UpdatedComputerInDb:
news.Add(new NewsDto(@new.AddedId,
localizer["Updated computer in database"],
@new.Date,
"computers",
$"{machine.Company.Name} {machine.Name}"));
break;
case NewsType.UpdatedConsoleInDb: case NewsType.UpdatedConsoleInDb:
news.Add(new NewsDto(@new.AddedId,
localizer["Updated console in database"],
@new.Date,
"consoles",
$"{machine.Company.Name} {machine.Name}"));
break;
case NewsType.UpdatedComputerInCollection: case NewsType.UpdatedComputerInCollection:
news.Add(new NewsDto(@new.AddedId,
localizer["Updated computer in collection"],
@new.Date,
"computers",
$"{machine.Company.Name} {machine.Name}"));
break;
case NewsType.UpdatedConsoleInCollection: case NewsType.UpdatedConsoleInCollection:
news.Add(new NewsDto(@new.AddedId, news.Add(new NewsDto
localizer["Updated console in collection"], {
@new.Date, Id = @new.Id,
"consoles", AffectedId = @new.AddedId,
$"{machine.Company.Name} {machine.Name}")); Timestamp = @new.Date,
Type = @new.Type,
Controller =
@new.Type is NewsType.NewComputerInDb
or NewsType.NewComputerInCollection
or NewsType.UpdatedComputerInDb
or NewsType.UpdatedComputerInCollection
? "computers"
: "consoles",
ItemName = $"{machine.Company.Name} {machine.Name}"
});
break; break;