-
Notifications
You must be signed in to change notification settings - Fork 120
Expand file tree
/
Copy pathHomeController.cs
More file actions
77 lines (64 loc) · 2.36 KB
/
HomeController.cs
File metadata and controls
77 lines (64 loc) · 2.36 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
using Microsoft.AspNetCore.Mvc;
using Rotativa.AspNetCore.DemoApp.Models;
using System.Diagnostics;
using Rotativa.AspNetCore.Options;
using System.Data.Common;
namespace Rotativa.AspNetCore.DemoApp.Controllers
{
public class HomeController : Controller
{
private readonly ILogger<HomeController> _logger;
public HomeController(ILogger<HomeController> logger)
{
_logger = logger;
}
public IActionResult Index()
{
return View();
}
public IActionResult Contact()
{
ViewData["Message"] = "Your contact page.";
return new ViewAsPdf(viewData: ViewData);
}
public IActionResult Privacy()
{
return new ViewAsPdf();
}
public IActionResult EphemerideWithAction()
{
return new ActionAsPdf("Ephemeride", new { d=DateTime.Now , day= DateTime.Now.DayOfWeek.ToString() } );
}
public IActionResult Ephemeride( DateTime d, string day)
{
Ephemeride ephemeride = new Ephemeride();
ephemeride.DateOfTheDay = d;
ephemeride.TheDayToday = day;
ViewBag.testViewBag = new List<string> { "val 1", " val 2" };
return View("EphemerideDemo", ephemeride);
}
public IActionResult ContactImage()
{
ViewData["Message"] = "Your contact page image.";
// Example on how to set custom data.
// For demo purposes we changed the name of the view, and specified that it isn't a partial view.
// IsPartialView is false by default. We add some additional ViewData.
// Using custom options 'Format' and 'Quality' as a demo.
// See AsImageResultBase for more options.
return new ViewAsImage("ContactDemo", isPartialView: false, viewData: ViewData, setBaseUrl: true)
{
Format = ImageFormat.png,
Quality = 90
};
}
public IActionResult PrivacyImage()
{
return new ViewAsImage();
}
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
public IActionResult Error()
{
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
}
}
}