0
0
MyDarling/Controllers/BundlesController.cs

36 lines
719 B
C#
Raw Normal View History

2023-02-16 07:47:09 +03:00
using Microsoft.AspNetCore.Mvc;
2023-02-16 08:28:59 +03:00
using Microsoft.EntityFrameworkCore;
2023-02-16 07:47:09 +03:00
using MyDarling.Models;
namespace MyDarling.Controllers
{
public class BundlesController : Controller
{
private IRepository repository;
2023-02-16 08:28:59 +03:00
2023-02-16 07:47:09 +03:00
public BundlesController(IRepository repository)
{
this.repository = repository;
}
2023-02-16 08:28:59 +03:00
2023-02-16 07:47:09 +03:00
public ActionResult Index()
{
return View(repository);
}
2023-02-16 08:28:59 +03:00
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");
}
2023-02-16 07:47:09 +03:00
}
}