-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathHomeController.cs
52 lines (44 loc) · 1.7 KB
/
HomeController.cs
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
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using netcore_postgres_oauth_boiler.Models;
using System;
using System.Diagnostics;
namespace netcore_postgres_oauth_boiler.Controllers
{
public class HomeController : Controller
{
private readonly ILogger<HomeController> _logger;
public HomeController(ILogger<HomeController> logger)
{
_logger = logger;
}
public IActionResult Index()
{
// The original method is just 'return View()', this here is the data demo
if (HttpContext.Session.GetString("user") == null)
{
return View();
}
// Strongly typed data pass to View
var sampleData = new SampleDataListModel();
sampleData.SampleList.Add(new SampleDataModel("Burger shop", "438 Durham Ave."));
sampleData.SampleList.Add(new SampleDataModel("Hairdresser", "9489 Warren St."));
sampleData.SampleList.Add(new SampleDataModel("Grocery store", "807 NW. Newport Ave."));
// Weakly typed data pass to View
var l = new string[] { "Milk","Eggs","Flour"};
ViewData["data"] = String.Join(",", l);
ViewData["dataTitle"] = "Shopping List:";
return View(sampleData);
}
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
public IActionResult Error()
{
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
}
public new IActionResult NotFound()
{
return View();
}
}
}