blob: 9305766e68d3904f6d96a5cd647a4879c79b7bf9 (
plain) (
blame)
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
|
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
namespace I2R.LightNews.Pages;
public class IndexModel : PageModel
{
private readonly ILogger<IndexModel> _logger;
private readonly GrabberService _grabber;
public IndexModel(ILogger<IndexModel> logger, GrabberService grabber) {
_logger = logger;
_grabber = grabber;
}
public NewsSource Source { get; set; }
public async Task<ActionResult> OnGet(string site) {
if (site.IsNullOrWhiteSpace()) {
return Redirect("/nrk");
}
Source = site switch {
"nrk" => await _grabber.GrabNrkAsync(),
_ => await _grabber.GrabNrkAsync()
};
return Page();
}
}
|