blob: 7c0a9c24b393468868255947801fed35e4cfdb2b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
using System.Text;
using Enmarcha.Experimental.ServiceViewer.Data;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
namespace Enmarcha.Experimental.ServiceViewer.Controllers;
[Controller]
[Route("")]
public class StylesheetController : Controller
{
private readonly AppDbContext _db;
public StylesheetController(AppDbContext db)
{
_db = db;
}
[HttpGet("stylesheets/routecolours.css")]
public IActionResult GetRouteColoursSheet()
{
var routeColours = _db.Routes
.Select(r => new { Id = r.SafeId, r.Color, r.TextColor })
.ToListAsync();
StringBuilder sb = new();
foreach (var route in routeColours.Result)
{
sb.Append($".route-{route.Id} {{");
sb.Append($"--route-color: #{route.Color};");
sb.Append($"--route-text: #{route.TextColor};");
sb.Append($"--route-color-semi: #{route.Color}4d;");
sb.Append($"--route-text-semi: #{route.TextColor}4d;");
sb.Append('}');
}
sb.Append('}');
return Content(sb.ToString(), "text/css", Encoding.UTF8);
}
}
|