예제 #1
0
        public ActionResult DeleteConfirmed(int id)
        {
            Candidat candidat = db.Candidats.Find(id);

            db.Candidats.Remove(candidat);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
예제 #2
0
        public ActionResult Create([Bind(Include = "redouble_1ere_annee,redouble_2eme_annee,redouble_3eme_annee,note_S1,note_S2," +
                                                   "note_S3,note_S4,note_S5,note_S6")]
                                   Candidat candidat3)
        {
            Candidat c1 = new Candidat();

            c1 = (Candidat)Session["etape1_can"];
            Candidat c2 = new Candidat();

            c2 = (Candidat)Session["etape2_can"];

            Candidat candidat = new Candidat(c1.nom, c1.prnom, c1.date_naissance, c1.lieu_naissance, c1.adresse, c1.nationalite, c1.ville, c1.tel, c1.fix, c1.cin, c1.email, c1.password, c1.password2
                                             , c2.cne, c2.type_bac, c2.annee_bac, c2.mention_bac, c2.diplome, c2.ecole, c2.ville_ecole, candidat3.redouble_1ere_annee, candidat3.redouble_2eme_annee, candidat3.redouble_3eme_annee, candidat3.note_S1, candidat3.note_S2,
                                             candidat3.note_S3, candidat3.note_S4, candidat3.note_S5, candidat3.note_S6, c1.photo_identite, c2.scan_bac, c2.scan_diplome, c2.filiere_choisie);

            //Génerer score
            //note diplome
            if (candidat.note_S5 == null && candidat.note_S6 == null)
            {
                double?note = (candidat.note_S1 + candidat.note_S2 + candidat.note_S3 + candidat.note_S4) / 4;
                if (note <= 12)
                {
                    candidat.score = 0;
                }
                if (12 < note && note <= 14)
                {
                    candidat.score = 4;
                }
                if (14 < note && note <= 16)
                {
                    candidat.score = 8;
                }
                if (16 < note && note <= 18)
                {
                    candidat.score = 12;
                }
            }
            if (candidat.note_S5 != null && candidat.note_S6 != null)
            {
                double?note = (candidat.note_S1 + candidat.note_S2 + candidat.note_S3 + candidat.note_S4 + candidat.note_S5 + candidat.note_S6) / 4;
                if (note <= 12)
                {
                    candidat.score = 0;
                }
                if (12 < note && note <= 14)
                {
                    candidat.score = 4;
                }
                if (14 < note && note <= 16)
                {
                    candidat.score = 8;
                }
                if (16 < note && note <= 18)
                {
                    candidat.score = 12;
                }
            }
            //redoublement
            if (candidat.redouble_1ere_annee == true || candidat.redouble_2eme_annee == true || candidat.redouble_3eme_annee == true)
            {
                candidat.score = 0;
            }
            //type bac
            switch (candidat.type_bac)
            {
            case "math": candidat.score += 3;
                break;

            case "technique": candidat.score += 2;
                break;

            case "pc": candidat.score += 1;
                break;

            default:
                candidat.score += 0;
                break;
            }
            //mention bac
            switch (candidat.mention_bac)
            {
            case "excellent":
                candidat.score += 3;
                break;

            case "tres bien":
                candidat.score += 2;
                break;

            case "bien":
                candidat.score += 1;
                break;

            default:
                candidat.score += 0;
                break;
            }

            ModelState.Clear();
            if (ModelState.IsValid == true)
            {
                try
                {
                    db.Candidats.Add(candidat);
                    db.SaveChanges();
                }
                catch (DbEntityValidationException e)
                {
                    var errors = db.GetValidationErrors();
                    ViewBag.nom = errors;
                    return(View());
                }
            }
            return(RedirectToAction("confirmation"));
        }