public ActionResult EditCandidat(CandidatsFormations model)
        {
            CandidatsFormations candidat = db.CandidatsFormations.Find(model.Id);

            ViewBag.Financements = db.TypedeFinancements.ToList();
            if (ModelState.IsValidField("Nom") && ModelState.IsValidField("Prenom") && ModelState.IsValidField("Grade") &&
                ModelState.IsValidField("NumeroLicence") && ModelState.IsValidField("Email") && ModelState.IsValidField("Telephone") &&
                ModelState.IsValidField("Tuteurs.Nom") && ModelState.IsValidField("Tuteurs.Prenom") && ModelState.IsValidField("Tuteurs.Email") &&
                ModelState.IsValidField("Tuteurs.NumeroLicence")
                )
            {
                db.CandidatsFormations.Attach(candidat);
                candidat.Nom                  = model.Nom;
                candidat.Prenom               = model.Prenom;
                candidat.NumeroLicence        = model.NumeroLicence;
                candidat.Grade                = model.Grade;
                candidat.Email                = model.Email;
                candidat.StructureAccueil     = model.StructureAccueil;
                candidat.TypedeFinancementsId = model.TypedeFinancementsId;
                candidat.DetailsFinancement   = model.DetailsFinancement;


                Tuteurs t = db.Tuteurs.Find(candidat.TuteursId);
                db.Tuteurs.Attach(t);
                t.Email         = model.Tuteurs.Email;
                t.Nom           = model.Tuteurs.Nom;
                t.Prenom        = model.Tuteurs.Prenom;
                t.NumeroLicence = model.Tuteurs.NumeroLicence;

                db.SaveChanges();
                return(RedirectToAction("Index", new { id = candidat.Id }));
            }
            return(View(candidat));
        }
Ejemplo n.º 2
0
 public CandidatFormationViewModel()
 {
     Tuteur       = new Tuteurs();
     Candidat     = new CandidatsFormations();
     Formation    = new Formations();
     Sexe         = new Sexes();
     Financements = new List <TypedeFinancements>();
 }
Ejemplo n.º 3
0
        public ActionResult NewCandidatSecondStep(CandidatFormationViewModel model)
        {
            if (ModelState.IsValidField("Candidat.Nom") && ModelState.IsValidField("Candidat.Prenom") && ModelState.IsValidField("Candidat.Grade") &&
                ModelState.IsValidField("Candidat.NumeroLicence") && ModelState.IsValidField("Candidat.Email") && ModelState.IsValidField("Candidat.Telephone") &&
                ModelState.IsValidField("Tuteur.Nom") && ModelState.IsValidField("Tuteur.Prenom") && ModelState.IsValidField("Tuteur.Email") &&
                ModelState.IsValidField("Tuteur.NumeroLicence")
                )
            {
                CandidatsFormations candidat = model.Candidat;

                Tuteurs t = db.Tuteurs.Find(model.Tuteur.Id);
                candidat.FormationId        = model.Formation.Id;
                candidat.TypedeFinancements = db.TypedeFinancements.Where(td => td.Id == model.FinancementId).FirstOrDefault();
                candidat.Tuteurs            = t;
                Resultats r = new Resultats();
                try
                {
                    if (t == null)
                    {
                        t = new Tuteurs();
                        t.NumeroLicence = model.Tuteur.NumeroLicence;
                        t.Nom           = model.Tuteur.Nom;
                        t.Prenom        = model.Tuteur.Prenom;
                        t.Email         = model.Tuteur.Email;
                        db.Tuteurs.Add(t);
                        db.SaveChanges();
                        candidat.Tuteurs = t;
                    }

                    db.Resultats.Add(r);
                    db.CandidatsFormations.Add(candidat);
                    db.SaveChanges();
                    r.CandidatsFormations = candidat;
                    db.SaveChanges();
                }
                catch (Exception e)
                {
                }
                return(RedirectToAction("ShowASAC", "Formations", new { id = model.Formation.Id }));
            }
            else
            {
                ViewBag.Financements = db.TypedeFinancements.ToList();
            }
            return(View(model));
        }
Ejemplo n.º 4
0
        private Boolean IsExistInWebServiceTuteur(Tuteurs model)
        {
            /**
             * Create url from licencie
             */
            String url          = "http://www.ffjda.org/ws_mobile/webRestGet/service.svc/infosInscriptionASP/";
            String numLicChange = model.NumeroLicence.Replace("*", "@").Replace(" ", "§");

            /**
             * Make the request
             */
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url + numLicChange);

            try
            {
                WebResponse response = request.GetResponse();
                using (Stream responseStream = response.GetResponseStream())
                {
                    // Reader to open http response
                    StreamReader reader = new StreamReader(responseStream, Encoding.UTF8);
                    String       back   = reader.ReadToEnd();
                    // test le retour de la fonction web
                    // Si j'ai rien le licencie n'existe pas, sinon
                    if (back.Length == 0 || back == null)
                    {
                        return(false);
                    }

                    // Use dictionnary to reade Json string
                    var dict = new JavaScriptSerializer().Deserialize <Dictionary <string, object> >(back);
                    // List to skip first stage
                    ArrayList list = (ArrayList)dict["infosInscriptionASPResult"];
                    // Je récupére tous les items de ma chaine json
                    Dictionary <String, Object> items = (Dictionary <String, Object>)list[0];
                    // Et je traite ceux que je veux
                    object item;
                    items.TryGetValue("numLicence", out item);
                    model.NumeroLicence = (String)item;
                    // Si le num licence est vide alors la licence n'existe pas
                    if (model.NumeroLicence == null || model.NumeroLicence.Length == 0)
                    {
                        return(false);
                    }
                    items.TryGetValue("mail", out item);
                    model.Email = (String)item;
                    items.TryGetValue("prenom", out item);
                    model.Prenom = (String)item;
                    items.TryGetValue("nom", out item);
                    model.Nom = (String)item;
                    return(true);
                }
            }
            catch (WebException ex)
            {
                WebResponse errorResponse = ex.Response;
                using (Stream responseStream = errorResponse.GetResponseStream())
                {
                    StreamReader reader    = new StreamReader(responseStream, Encoding.GetEncoding("utf-8"));
                    String       errorText = reader.ReadToEnd();
                    // log errorText
                }
                throw;
            }
        }