blob: aeefebbe70bfb522a5ee341307d2beb49d836cde (
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
40
41
42
43
44
45
46
47
|
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using MyDarling.Models;
namespace MyDarling.Controllers
{
public class BundlesController : Controller
{
private IRepository repository;
public BundlesController(IRepository repository)
{
this.repository = repository;
}
public ActionResult Index()
{
return View(repository);
}
public ActionResult Edit(int id)
{
return View(repository.Bundles.Where(b => b.Id == id).FirstOrDefault());
}
public ActionResult Delete(int id)
{
var bundle = repository.Bundles.Where(b => b.Id == id).FirstOrDefault();
if (bundle != null)
{
repository.Remove(bundle);
}
return RedirectToAction("Index");
}
public ActionResult Add()
{
return View();
}
[HttpPost]
public ActionResult Add(UnderwearBundle b)
{
repository.Add(b);
return RedirectToAction("Index");
}
}
}
|