Files
yavsc/src/Yavsc/Controllers/Contracting/SIRENExceptionsController.cs
Paul Schneider a9b809f5e5
Some checks failed
Dotnet build and test / log-the-inputs (push) Failing after 1s
Dotnet build and test / build (push) Failing after 1s
Refactoring
The main server owns the migrations, it's the server part,
it's simpler.

It's Yavsc, not one of its lib.
2025-07-15 20:17:39 +01:00

123 lines
3.4 KiB
C#

using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Yavsc.Helpers;
using Yavsc.Models;
using Yavsc.Models.Billing;
using Yavsc.Server.Helpers;
namespace Yavsc.Controllers
{
[Authorize(Roles="Administrator")]
public class SIRENExceptionsController : Controller
{
private readonly ApplicationDbContext _context;
public SIRENExceptionsController(ApplicationDbContext context)
{
_context = context;
}
// GET: SIRENExceptions
public IActionResult Index()
{
return View(_context.ExceptionsSIREN.ToList());
}
// GET: SIRENExceptions/Details/5
public IActionResult Details(string id)
{
if (id == null)
{
return NotFound();
}
ExceptionSIREN exceptionSIREN = _context.ExceptionsSIREN.Single(m => m.SIREN == id);
if (exceptionSIREN == null)
{
return NotFound();
}
return View(exceptionSIREN);
}
// GET: SIRENExceptions/Create
public IActionResult Create()
{
return View();
}
// POST: SIRENExceptions/Create
[HttpPost]
[ValidateAntiForgeryToken]
public IActionResult Create(ExceptionSIREN exceptionSIREN)
{
if (ModelState.IsValid)
{
_context.ExceptionsSIREN.Add(exceptionSIREN);
_context.SaveChanges(User.GetUserId());
return RedirectToAction("Index");
}
return View(exceptionSIREN);
}
// GET: SIRENExceptions/Edit/5
public IActionResult Edit(string id)
{
if (id == null)
{
return NotFound();
}
ExceptionSIREN exceptionSIREN = _context.ExceptionsSIREN.Single(m => m.SIREN == id);
if (exceptionSIREN == null)
{
return NotFound();
}
return View(exceptionSIREN);
}
// POST: SIRENExceptions/Edit/5
[HttpPost]
[ValidateAntiForgeryToken]
public IActionResult Edit(ExceptionSIREN exceptionSIREN)
{
if (ModelState.IsValid)
{
_context.Update(exceptionSIREN);
_context.SaveChanges(User.GetUserId());
return RedirectToAction("Index");
}
return View(exceptionSIREN);
}
// GET: SIRENExceptions/Delete/5
[ActionName("Delete")]
public IActionResult Delete(string id)
{
if (id == null)
{
return NotFound();
}
ExceptionSIREN exceptionSIREN = _context.ExceptionsSIREN.Single(m => m.SIREN == id);
if (exceptionSIREN == null)
{
return NotFound();
}
return View(exceptionSIREN);
}
// POST: SIRENExceptions/Delete/5
[HttpPost, ActionName("Delete")]
[ValidateAntiForgeryToken]
public IActionResult DeleteConfirmed(string id)
{
ExceptionSIREN exceptionSIREN = _context.ExceptionsSIREN.Single(m => m.SIREN == id);
_context.ExceptionsSIREN.Remove(exceptionSIREN);
_context.SaveChanges(User.GetUserId());
return RedirectToAction("Index");
}
}
}