| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- using CD67.FicheCollege.Entity;
- using CD67.FicheCollege.Factory;
- using CD67.FicheCollege.MVC.Models;
- using System.Net;
- using System.Web.Mvc;
- namespace CD67.FicheCollege.MVC.Controllers
- {
- 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 { });
- }
- }
- }
|