public ActionResult DeleteResponsable(decimal id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Responsable rp = db.Responsable.Find(id); Organismes orga = db.Organismes.Find(TempData["organisme"]); db.Organismes.Attach(orga); db.Responsable.Attach(rp); orga.Responsable.Remove(rp); db.SaveChanges(); System.Diagnostics.Debug.WriteLine("Nombre d'orgna pour le resp : " + rp.Organismes.Count()); if (rp.Organismes.Count() == 0) { db.Responsable.Remove(rp); } db.SaveChanges(); return(RedirectToAction("ShowResponsable", "Organismes", new { @id = orga.Id })); }
private Formations initializeFormation(decimal id) { // recupération de l'organisme auquel sera rattaché notre nouvelle formation Organismes orga = TempData["model"] as Organismes; // récupération du responsable pour le préremplir comme responsable pédagogique Responsable rp = db.Responsable.Find(((Responsable)Session["Responsable"]).Id); Formations formation = new Formations(); formation.TypedeFormationsId = id; formation.OrganismeId = orga.Id; formation.Habilitations = new Habilitations(); Personnel pers = new Personnel(); pers.Nom = rp.Nom; pers.Prenom = rp.Prenom; pers.Email = rp.Email; pers.Telephone = rp.Telephone; formation.Personnel = pers; return(formation); }
public ActionResult Create() { Organismes orga = new Organismes(); Lieux lieux = new Lieux(); orga.Lieux = lieux; return(View(orga)); }
public ActionResult AddResponsable() { ResponsableOrgaViewModel ro = TempData["responsable"] as ResponsableOrgaViewModel; Organismes organisme = db.Organismes.Find(ro.OrganismeId); ViewBag.libelleOrganisme = organisme.Libelle; return(View(ro)); }
public ActionResult Create2(Organismes orga) { if (ModelState.IsValid) { orga.LigueId = ((Ligues)Session["Ligue"]).Id; db.Organismes.Add(orga); db.SaveChanges(); return(RedirectToAction("Index", "Organismes")); } return(View(orga)); }
public ActionResult DeleteConfirmed(decimal id) { Organismes organismes = db.Organismes.Find(id); db.Lieux.Remove(organismes.Lieux); db.PresidentOrganisme.Remove(organismes.PresidentOrganisme); db.Personnel.Remove(organismes.Personnel); db.Personnel.Remove(organismes.Personnel1); db.Organismes.Remove(organismes); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Create(Organismes organismes) { if (ModelState.IsValidField("Libelle") && ModelState.IsValidField("NumeroDeclaration") && ModelState.IsValidField("AnneeDeclaration") && ModelState.IsValidField("Lieux.Adresse") && ModelState.IsValidField("Lieux.CodePostal") && ModelState.IsValidField("Lieux.Ville") && ModelState.IsValidField("Lieux.Telephone") && ModelState.IsValidField("Lieux.Email") ) { TempData["model"] = organismes; return(RedirectToAction("Create2")); } return(View(organismes)); }
public ActionResult Edit(Organismes organismes) { if (ModelState.IsValid) { //db.Entry(organismes).State = EntityState.Modified; var org = db.Organismes.Find(organismes.Id); db.Organismes.Attach(org); org.Libelle = organismes.Libelle; org.AnneeDeclaration = organismes.AnneeDeclaration; org.NumeroDeclaration = organismes.NumeroDeclaration; var tmp = db.Lieux.Find(organismes.LieuxId); db.Lieux.Attach(tmp); tmp.Adresse = organismes.Lieux.Adresse; tmp.CodePostal = organismes.Lieux.CodePostal; tmp.Ville = organismes.Lieux.Ville; tmp.Telephone = organismes.Lieux.Telephone; tmp.Email = organismes.Lieux.Email; var pres = db.PresidentOrganisme.Find(organismes.PresidentId); db.PresidentOrganisme.Attach(pres); pres.Nom = organismes.PresidentOrganisme.Nom; pres.Prenom = organismes.PresidentOrganisme.Prenom; pres.Email = organismes.PresidentOrganisme.Email; pres.Telephone = organismes.PresidentOrganisme.Telephone; var coor = db.Personnel.Find(organismes.CoordinateurId); db.Personnel.Attach(coor); coor.Nom = organismes.Personnel.Nom; coor.Prenom = organismes.Personnel.Prenom; coor.Email = organismes.Personnel.Email; coor.Telephone = organismes.Personnel.Telephone; var dir = db.Personnel.Find(organismes.DirecteurId); db.Personnel.Attach(dir); dir.Nom = organismes.Personnel1.Nom; dir.Prenom = organismes.Personnel1.Prenom; dir.Email = organismes.Personnel1.Email; dir.Telephone = organismes.Personnel1.Telephone; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(organismes)); }
public ActionResult Delete(decimal id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Organismes organismes = db.Organismes.Find(id); if (organismes == null) { return(HttpNotFound()); } return(View(organismes)); }
public ActionResult EtatFormationDESJEPS(decimal id) { if (id == null) { RedirectToAction("Organismes", "AccesResponsable"); } Organismes org = db.Organismes.Find(id); ListeFormationEtatViewModel formations = new ListeFormationEtatViewModel(); formations.organisme = org; formations.enCours = db.Formations.Where(f => f.OrganismeId == org.Id && f.TypedeFormationsId == 7 && f.FormationEnded == false).OrderByDescending(f => f.DateDebut); formations.termine = db.Formations.Where(f => f.OrganismeId == org.Id && f.TypedeFormationsId == 7 && f.FormationEnded == true).OrderByDescending(f => f.DateDebut); TempData["model"] = org; return(View(formations)); }
public ActionResult Create2() { Organismes orga = TempData["model"] as Organismes; if (orga == null) { return(RedirectToAction("Create")); } orga.PresidentOrganisme = new PresidentOrganisme(); orga.Personnel = new Personnel(); orga.Personnel1 = new Personnel(); return(View(orga)); }
public ActionResult ShowResponsable(SearchResponsableViewModel sr) { Organismes org = db.Organismes.Find(sr.OrganismeId); sr.organisme = org; ResponsableOrgaViewModel Ro = new ResponsableOrgaViewModel(); Ro.responsable.Licence = sr.NumeroLicence; // Tempdata use when delete on responsable is called TempData["organisme"] = org.Id; if (ModelState.IsValid) { if (!org.Responsable.Any(r => r.Licence == sr.NumeroLicence)) { if (db.Responsable.Any(r => r.Licence == sr.NumeroLicence)) { Ro.responsable = db.Responsable.Where(r => r.Licence == sr.NumeroLicence).First();; } else if (IsExistInWebService(Ro.responsable)) { } else { ModelState.AddModelError("NumeroLicence", "La personne avec le numéro de licence " + sr.NumeroLicence + " n'existe pas ou est déjà présente pour cette organisme."); return(View(sr)); } Ro.OrganismeId = sr.OrganismeId; TempData["responsable"] = Ro; return(RedirectToAction("AddResponsable")); } else { ModelState.AddModelError("NumeroLicence", "La personne avec le numéro de licence " + sr.NumeroLicence + " n'existe pas ou est déjà présente pour cette organisme."); return(View(sr)); } } return(View(sr)); }
public ActionResult AddResponsable(ResponsableOrgaViewModel ro) { Organismes organisme = db.Organismes.Find(ro.OrganismeId); ViewBag.libelleOrganisme = organisme.Libelle; if (ModelState.IsValid) { db.Organismes.Attach(organisme); Responsable toUpdate; System.Diagnostics.Debug.WriteLine("Nombre d'orgna pour le resp : " + ro.responsable.Id); if (ro.responsable.Id > 0) { toUpdate = db.Responsable.Find(ro.responsable.Id); db.Responsable.Attach(toUpdate); if (toUpdate.Password != ro.responsable.Password && toUpdate.Password != encrypt(ro.responsable.Password)) { toUpdate.Password = encrypt(ro.responsable.Password); } } else { toUpdate = new Responsable(); toUpdate.Password = encrypt(ro.responsable.Password); } toUpdate.Licence = ro.responsable.Licence; toUpdate.Nom = ro.responsable.Nom; toUpdate.Prenom = ro.responsable.Prenom; toUpdate.Email = ro.responsable.Email; toUpdate.Telephone = ro.responsable.Telephone; organisme.Responsable.Add(toUpdate); db.SaveChanges(); return(RedirectToAction("ShowResponsable", "Organismes", new { @id = ro.OrganismeId })); } return(View(ro)); }
public SearchResponsableViewModel() { organisme = new Organismes(); }