-
Notifications
You must be signed in to change notification settings - Fork 25.3k
/
ToDoController.cs
53 lines (46 loc) · 1.46 KB
/
ToDoController.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
53
using System.Linq;
using Microsoft.AspNetCore.Mvc;
using ViewComponentSample.Models;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;
namespace ViewComponentSample.Controllers
{
public class ToDoController : Controller
{
private readonly ToDoContext _ToDoContext;
public ToDoController(ToDoContext context)
{
_ToDoContext = context;
// EnsureCreated() is used to call OnModelCreating for In-Memory databases as migration is not possible
// see: https://github.com/aspnet/EntityFrameworkCore/issues/11666
_ToDoContext.Database.EnsureCreated();
}
public IActionResult Index()
{
var model = _ToDoContext.ToDo.ToList();
return View(model);
}
#region snippet_IndexVC
public IActionResult IndexVC()
{
return ViewComponent("PriorityList", new { maxPriority = 3, isDone = false });
}
#endregion
public async Task<IActionResult> IndexFinal()
{
return View(await _ToDoContext.ToDo.ToListAsync());
}
public IActionResult IndexNameof()
{
return View(_ToDoContext.ToDo.ToList());
}
public IActionResult IndexTypeof()
{
return View(_ToDoContext.ToDo.ToList());
}
public IActionResult IndexFirst()
{
return View(_ToDoContext.ToDo.ToList());
}
}
}