| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- using CD67.FicheCollege.Entity;
- using CD67.FicheCollege.Factory;
- using CD67.FicheCollege.MVC.Models;
- using CD67.PIMP.MVC.Internal;
- using System.Net;
- using System.Web.Mvc;
- namespace CD67.FicheCollege.MVC.Controllers
- {
- [Acces(groupes = "Admin")]
- public class GroupesController : Controller
- {
- private Entities db = new Entities();
- // GET: Groupes
- public ActionResult Index()
- {
- GroupeFactory fact = new GroupeFactory(db);
- GroupeIndexViewModel model = new GroupeIndexViewModel(fact.getAll());
- return View(model);
- }
- // GET: Groupes
- public ActionResult Details(int? id)
- {
- if (id == null)
- {
- return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
- }
- GroupeFactory fact = new GroupeFactory(db);
- Groupe groupe = fact.getById(id);
- groupe.hydrate();
- GroupeViewModel model = new GroupeViewModel(groupe);
- return View(model);
- }
- protected override void Dispose(bool disposing)
- {
- if (disposing)
- {
- db.Dispose();
- }
- base.Dispose(disposing);
- }
- [HttpPost]
- public JsonResult AddUser(string sid, int groupe_id)
- {
- Utilisateur utilisateur = new Utilisateur
- {
- Sid = sid,
- GroupeId = groupe_id
- };
- UtilisateurFactory fact = new UtilisateurFactory(db);
- fact.add(ref utilisateur);
- utilisateur.hydrate();
- return Json(utilisateur.flat());
- }
- [HttpPost]
- public JsonResult RemoveUser(int? id)
- {
- if (id != null)
- {
- UtilisateurFactory fact = new UtilisateurFactory(db);
- Utilisateur utilisateur = fact.getById(id);
- fact.delete(ref utilisateur);
- return Json(utilisateur.flat());
- }
- return Json(new { });
- }
- }
- }
|