public IEnumerable <CorrectionModel> corr(string type_fil) { GestionConcourDbContext db = new GestionConcourDbContext(); var res = (from c in db.Candidats join d in db.Diplomes on c.Cne equals d.Cne join e in db.Filieres on c.ID equals e.ID join b in db.CouncourEcrits on c.Cne equals b.Cne where (c.Presence == true && c.Niveau == 3 && e.Nom == type_fil) select new CorrectionModel { Num_dossier = c.Num_dossier, Cin = c.Cin, Cne = c.Cne, NoteMath = b.NoteMath, NoteSpecialite = b.NoteSpecialite, Nom = c.Nom, Prenom = c.Prenom, //Filiere = b.Nom, Diplome = d.Type, Filiere = e.Nom, }).ToList(); return(res); }
public string uploadEpreuve(UploadModel epreuve) { HttpPostedFileBase file = epreuve.file; string matiere = epreuve.matiere; string annee = epreuve.annee; string response = "1"; if (file != null && file.ContentLength > 0) { try { string path = Path.Combine(System.Web.HttpContext.Current.Server.MapPath("~/Epreuves/"), file.FileName); file.SaveAs(path); GestionConcourDbContext db = new GestionConcourDbContext(); Epreuves epr = new Epreuves(); epr.NomFichier = file.FileName; epr.Matiere = matiere; epr.Annee = annee; db.Epreuves.Add(epr); db.SaveChanges(); } catch (Exception ex) { response = ex.Message; } } else { response = "0"; } return(response); }
public ActionResult Login(Candidat candidat) { GestionConcourDbContext db = new GestionConcourDbContext(); var x = db.Candidats.Where(c => c.Cne == candidat.Cne && c.Cin == candidat.Cin && c.Password == candidat.Password).SingleOrDefault(); if (x == null) { TempData["error"] = "False Credential"; return(Redirect("Login")); } else { Session["cne"] = candidat.Cne; Session["niveau"] = x.Niveau; Session["role"] = "user"; Session["photo"] = candidat.Photo; if (x.Verified == 1) { return(RedirectToAction("Index", "Home")); } else { return(RedirectToAction("Step1", "Auth")); } } }
public IEnumerable <CorrectionModel4> corr4(string type_fil) { GestionConcourDbContext db = new GestionConcourDbContext(); var res = (from c in db.Candidats join d in db.Diplomes on c.Cne equals d.Cne join e in db.Filieres on c.ID equals e.ID join b in db.CouncourOrals on c.Cne equals b.Cne where (c.Presence == true && c.Niveau == 4 && e.Nom == type_fil) select new CorrectionModel4 { Num_dossier = c.Num_dossier, Cin = c.Cin, Cne = c.Cne, Nom = c.Nom, Prenom = c.Prenom, Etablissement = d.Etablissement + " - " + d.VilleObtention, Filiere = e.Nom, Diplome = d.Type, VilleObtention = d.VilleObtention, Specialite = d.Specialite, Classement = b.Classement, }).ToList(); return(res); }
public JsonResult Image(HttpPostedFileBase file) { string response = " "; if (file != null && file.ContentLength > 0) { try { String extension = Path.GetExtension(file.FileName); Random r = new Random(); int rInt = r.Next(0, 10000); string fileName = rInt.ToString() + extension.ToLower(); string path = Path.Combine(Server.MapPath("~/Pictures/userPic"), fileName); file.SaveAs(path); string cne = Session["cne"].ToString(); GestionConcourDbContext db = new GestionConcourDbContext(); var x = db.Candidats.Where(c => c.Cne == cne).SingleOrDefault(); x.Photo = fileName; db.SaveChanges(); Session["photo"] = fileName; response = fileName; } catch (Exception ex) { response = "icon.png"; } } else { response = "icon.png"; } return(Json(response, JsonRequestBehavior.AllowGet)); }
public ActionResult Verify(string cne) { GestionConcourDbContext db = new GestionConcourDbContext(); var x = db.Candidats.Where(c => c.Cne == cne).SingleOrDefault(); x.Verified = 1; db.SaveChanges(); TempData["message"] = "Account Verified Succefully"; return(Redirect("Login")); }
public IEnumerable <SearchModel3> restoreCorbeil(string cne, int niveau) { GestionConcourDbContext db = new GestionConcourDbContext(); var y = db.Corbeilles.Where(cor => cor.CNE == cne).SingleOrDefault(); db.Corbeilles.Remove(y); db.SaveChanges(); var x = this.info(niveau); return(x); }
public IEnumerable <SearchModel3> conformCandidat(string cne, int niveau) { GestionConcourDbContext db = new GestionConcourDbContext(); var x = db.Candidats.Where(c => c.Cne == cne).SingleOrDefault(); x.Conforme = !x.Conforme; db.SaveChanges(); var y = this.info(niveau); return(y); }
public IEnumerable <SearchModel3> deleteCandidat(string cne, int niveau) { GestionConcourDbContext db = new GestionConcourDbContext(); Candidat cand = db.Candidats.Where(c => c.Cne == cne).SingleOrDefault(); Corbeille corb = new Corbeille(); corb.CNE = cne; db.Corbeilles.Add(corb); db.SaveChanges(); var x = this.info(niveau); return(x); }
public IEnumerable <DiplomeFichierModel> diplomeFile(string cne, int niveau) { GestionConcourDbContext db = new GestionConcourDbContext(); var x = (from f in db.Fichiers join c in db.Candidats on f.Cne equals c.Cne where f.Cne == cne where c.Niveau == niveau select new DiplomeFichierModel { ID = f.ID, nom = f.nom }).ToList(); return(x); }
public ActionResult Profil() { if (Session["cne"] == null) { return(RedirectToAction("Login", "Auth")); } GestionConcourDbContext db = new GestionConcourDbContext(); Candidat c1 = db.Candidats.Where(p => p.Cne == Session["cne"].ToString()).SingleOrDefault(); if (c1.Verified == 0) { return(RedirectToAction("Step1", "Auth")); } return(View(c1)); }
public ActionResult PasswordOublie(string email) { GestionConcourDbContext db = new GestionConcourDbContext(); Candidat candidat = db.Candidats.Where(c => c.Email == email).SingleOrDefault(); Random random = new Random(); const string pool = "abcdefghijklmnopqrstuvwxyz0123456789"; var chars = Enumerable.Range(0, 7) .Select(x => pool[random.Next(0, pool.Length)]); string password = new string(chars.ToArray()); try { candidat.Password = password; db.SaveChanges(); var fromAddress = new MailAddress("*****@*****.**", "From ENSAS "); var toAddress = new MailAddress(email, "To Name"); const string fromPassword = "******"; const string subject = "Restauration de mot de pass"; //string body = "<a href=\"http://localhost:49969/Auth/Verify?cne="+candidat.Cne+" \">Link</a><br /><p> this is the password : "******"</p>"; string body = "<div class=\"container\"><div class=\"row\"><img src=\"https://lh3.googleusercontent.com/proxy/g_QnANEsQGJPGvR4haGBTi-kr2n32DU-eArBRKuJWtpgPCHQbz-RINzL6FzIc1TQs0a80Vfkaew6umTHHPQgHTE4l_g \" /></div><br><div class=\"alert alert-danger\"><strong><span style=\"color:'red'\">Vous trouverez votre nouveau mot de passe au dessous</span></strong><br></div><div class=\"row\"><div class=\"card\" style=\"width: 18rem;\"><div class=\"card-body\"><strong>Nom :</strong><span>" + candidat.Nom + "</span><br /><strong>Prenom : </strong><span>" + candidat.Prenom + "</span><br /><strong>CNE : </strong><span>" + candidat.Cne + "</span><br /><strong>CIN : </strong><span>" + candidat.Cin + "</span><br /><strong>Password : </strong><span>" + candidat.Password + "</span><br /></div></div></div></div>"; var smtp = new SmtpClient { Host = "smtp.gmail.com", Port = 587, EnableSsl = true, DeliveryMethod = SmtpDeliveryMethod.Network, Credentials = new NetworkCredential(fromAddress.Address, fromPassword), Timeout = 60000 }; using (var message = new MailMessage(fromAddress, toAddress) { Subject = subject, Body = body }) { message.IsBodyHtml = true; smtp.Send(message); } TempData["message"] = "Email Sent Succefully"; return(View()); } catch (Exception ex) { TempData["error"] = "Entrer des données valides"; return(View()); } }
public IEnumerable <SearchModel3> info(int niveau) { GestionConcourDbContext db = new GestionConcourDbContext(); var x = (from c in db.Candidats join a in db.AnneeUniversitaires on c.Cne equals a.Cne join b in db.Baccalaureats on c.Cne equals b.Cne join concour in db.CouncourEcrits on c.Cne equals concour.Cne join d in db.Diplomes on c.Cne equals d.Cne join corb in db.Corbeilles on c.Cne equals corb.CNE join oral in db.CouncourOrals on c.Cne equals oral.Cne where c.Niveau == niveau select new SearchModel3 { Nom = c.Nom, Prenom = c.Prenom, Sexe = c.Sexe, NoteBac = b.NoteBac, Note1 = a.Semestre1, Note2 = a.Semestre2, Note3 = a.Semestre3, Note4 = a.Semestre4, Dossier = c.Num_dossier, Convoque = c.Convoque, Math = concour.NoteMath, Specialite = concour.NoteSpecialite, Matricule = c.Matricule, Email = c.Email, Lieu_Naiss = c.LieuNaissance, Nationalite = c.Nationalite, Adress = c.Adresse, Ville = c.Ville, Type_dip = d.Type, note_Diplome = d.NoteDiplome, Etablissement = d.Etablissement, Ville_dip = d.VilleObtention, Date_inscription = c.DateInscription, Admis = c.Admis, Filiere = db.Filieres.Where(f => f.ID == c.ID).FirstOrDefault().Nom, Cin = c.Cin, Cne = c.Cne, NonConforme = c.Conforme }).ToList(); return(x); }
public ActionResult INDUS_Post4() { GestionConcourDbContext db = new GestionConcourDbContext(); var NOTES = Request["etudiants.Classement"].ToString().Split(','); var CNE = Request["etudiants.Cne"].ToString().Split(','); String d; for (int i = 0; i < CNE.Length; i++) { d = CNE[i].ToString(); ConcourOral con = db.CouncourOrals.Find(d); con.Classement = Int32.Parse(NOTES[i]); db.SaveChanges(); } return(RedirectToAction("index")); }
public ActionResult INFO_Post() { GestionConcourDbContext db = new GestionConcourDbContext(); var NOTES = Request["etudiants.NoteMath"].ToString().Split(','); var CNE = Request["etudiants.Cne"].ToString().Split(','); var NOTES2 = Request["etudiants.NoteSpecialite"].ToString().Split(','); //var CIN = Request["etudiants.Cin"].ToString().Split(','); String d; for (int i = 0; i < CNE.Length; i++) { d = CNE[i].ToString(); ConcourEcrit con = db.CouncourEcrits.Find(d); con.NoteMath = Double.Parse(NOTES[i]); con.NoteSpecialite = Double.Parse(NOTES2[i]); db.SaveChanges(); } return(RedirectToAction("index")); }
public IEnumerable <SearchModel3> specifiedSearch(string Criteria, string Key, string Diplome, string Filiere, int niveau) { //first select GestionConcourDbContext db = new GestionConcourDbContext(); db.Configuration.ProxyCreationEnabled = false; var x = (from c in db.Candidats join a in db.AnneeUniversitaires on c.Cne equals a.Cne join b in db.Baccalaureats on c.Cne equals b.Cne join concour in db.CouncourEcrits on c.Cne equals concour.Cne join d in db.Diplomes on c.Cne equals d.Cne where !db.Corbeilles.Select(g => g.CNE).ToList().Contains(c.Cne) join oral in db.CouncourOrals on c.Cne equals oral.Cne where c.Niveau == niveau select new SearchModel3 { Nom = c.Nom, Prenom = c.Prenom, Sexe = c.Sexe, NoteBac = b.NoteBac, Note1 = a.Semestre1, Note2 = a.Semestre2, Note3 = a.Semestre3, Note4 = a.Semestre4, Dossier = c.Num_dossier, Convoque = c.Convoque, Math = concour.NoteMath, Specialite = concour.NoteSpecialite, Matricule = c.Matricule, Email = c.Email, Lieu_Naiss = c.LieuNaissance, Nationalite = c.Nationalite, Adress = c.Adresse, Ville = c.Ville, Type_dip = d.Type, note_Diplome = d.NoteDiplome, Etablissement = d.Etablissement, Ville_dip = d.VilleObtention, Date_inscription = c.DateInscription, Admis = c.Admis, Filiere = db.Filieres.Where(f => f.ID == c.ID).FirstOrDefault().Nom, Cin = c.Cin, Cne = c.Cne, NonConforme = c.Conforme }); if (!String.IsNullOrEmpty(Key)) { if (Criteria == "convoque" || Criteria == "admis") { var param = Expression.Parameter(typeof(SearchModel3), "p"); var exp = Expression.Lambda <Func <SearchModel3, bool> >( Expression.Equal( Expression.Property(param, Criteria), Expression.Constant(bool.Parse(Key)) ), param ); x = x.Where(exp); } else { //first select var param = Expression.Parameter(typeof(SearchModel3), "p"); var exp = Expression.Lambda <Func <SearchModel3, bool> >( Expression.Equal( Expression.Property(param, Criteria), Expression.Constant(Key) ), param ); x = x.Where(exp); } } if (Filiere != "0") { x = x.Where(n => n.Filiere == Filiere); } if (Diplome != "0") { x = x.Where(s => s.Type_dip == Diplome); } return(x.ToList().Select(v => { var fichier = db.Fichiers.Where(f => f.Cne == v.Cne).SingleOrDefault(); var part1 = ""; var part2 = ""; var part3 = ""; if (fichier != null) { if (fichier.nom.Split('|').Length == 1) { part1 = fichier.nom.Split('|')[0]; } else if (fichier.nom.Split('|').Length == 2) { part1 = fichier.nom.Split('|')[0]; part2 = fichier.nom.Split('|')[1]; } else { part1 = fichier.nom.Split('|')[0]; part2 = fichier.nom.Split('|')[1]; part3 = fichier.nom.Split('|')[2]; } } return new SearchModel3 { Nom = v.Nom, Prenom = v.Prenom, Sexe = v.Sexe, NoteBac = v.NoteBac, Note1 = v.Note1, Note2 = v.Note2, Note3 = v.Note3, Note4 = v.Note4, Note5 = v.Note5, Note6 = v.Note6, Dossier = v.Dossier, Convoque = v.Convoque, Math = v.Math, Specialite = v.Specialite, Matricule = v.Matricule, Email = v.Email, Lieu_Naiss = v.Lieu_Naiss, Nationalite = v.Nationalite, Adress = v.Adress, Ville = v.Ville, Type_dip = v.Type_dip, note_Diplome = v.note_Diplome, Etablissement = v.Etablissement, Ville_dip = v.Ville_dip, Date_inscription = v.Date_inscription, Admis = v.Admis, Filiere = v.Filiere, Cin = v.Cin, Cne = v.Cne, NonConforme = v.NonConforme, Diplome1 = part1, Diplome2 = part2, Diplome3 = part3 }; }).ToList()); }
public ActionResult Register(Candidat candidat) { GestionConcourDbContext db = new GestionConcourDbContext(); if (candidat.Niveau == 0) { ModelState.AddModelError("selectNiveau", "Selectionner un niveau"); } var y = db.Candidats.Where(c => c.Cne == candidat.Cne).SingleOrDefault(); if (y != null) { ModelState.AddModelError("UniqueCne", "Cne need to be unique"); } var z = db.Candidats.Where(c => c.Cin == candidat.Cin).SingleOrDefault(); if (z != null) { ModelState.AddModelError("UniqueCin", "Cin need to be unique"); } var w = db.Candidats.Where(c => c.Email == candidat.Email).SingleOrDefault(); if (w != null) { ModelState.AddModelError("UniqueEmail", "Email need to be unique"); } if (ModelState.IsValid) { candidat.DateInscription = DateTime.Now; candidat.DateNaissance = DateTime.Now; Random random = new Random(); const string pool = "abcdefghijklmnopqrstuvwxyz0123456789"; var chars = Enumerable.Range(0, 7) .Select(x => pool[random.Next(0, pool.Length)]); var charsMatricule = Enumerable.Range(0, 8) .Select(ww => pool[random.Next(0, pool.Length)]); candidat.Matricule = new string(charsMatricule.ToArray()).ToUpper(); candidat.Password = new string(chars.ToArray()); candidat.Verified = 0; candidat.Photo = "icon.jpg"; db.Candidats.Add(candidat); db.SaveChanges(); Diplome dip = new Diplome(); AnneeUniversitaire annUn = new AnneeUniversitaire(); Baccalaureat bac = new Baccalaureat(); ConcourEcrit concE = new ConcourEcrit(); ConcourOral concO = new ConcourOral(); //add row in diplome dip.Cne = candidat.Cne; db.Diplomes.Add(dip); db.SaveChanges(); //add row in anne annUn.Cne = candidat.Cne; db.AnneeUniversitaires.Add(annUn); db.SaveChanges(); //add row in bac bac.Cne = candidat.Cne; //bac.DateObtentionBac = DateTime.Now; db.Baccalaureats.Add(bac); db.SaveChanges(); //add in concours ecrit concE.Cne = candidat.Cne; db.CouncourEcrits.Add(concE); db.SaveChanges(); //add in concours oral concO.Cne = candidat.Cne; db.CouncourOrals.Add(concO); db.SaveChanges(); var fromAddress = new MailAddress("*****@*****.**", "From ENSAS"); var toAddress = new MailAddress(candidat.Email, "To Name"); const string fromPassword = "******"; const string subject = "Récupération du mot de passe"; //string body = "<a href=\"http://localhost:49969/Auth/Verify?cne="+candidat.Cne+" \">Link</a><br /><p> this is the password : "******"</p>"; string body = "<div class=\"container\"><div class=\"row\"><img src=\"https://lh3.googleusercontent.com/proxy/g_QnANEsQGJPGvR4haGBTi-kr2n32DU-eArBRKuJWtpgPCHQbz-RINzL6FzIc1TQs0a80Vfkaew6umTHHPQgHTE4l_g \" /></div><div class=\"row text-center\"><h2>Vous avez créer un compte dans la platforme d'acces au cycle d'ingénieur a ENSAS .</h2></div><div class=\"alert alert-danger\"><strong><span style=\"color:'red'\">Vous trouverez votre mot de pass au dessouss</span></strong><br></div><div class=\"row\"><div class=\"card\" style=\"width: 18rem;\"><div class=\"card-body\"><strong>Nom :</strong><span>" + candidat.Nom + "</span><br /><strong>Prenom : </strong><span>" + candidat.Prenom + "</span><br /><strong>CNE : </strong><span>" + candidat.Cne + "</span><br /><strong>CIN : </strong><span>" + candidat.Cin + "</span><br /><strong>Password : </strong><span>" + candidat.Password + "</span><br /></div></div></div></div>"; var smtp = new SmtpClient { Host = "smtp.gmail.com", Port = 587, EnableSsl = true, DeliveryMethod = SmtpDeliveryMethod.Network, Credentials = new NetworkCredential(fromAddress.Address, fromPassword), Timeout = 60000 }; using (var message = new MailMessage(fromAddress, toAddress) { Subject = subject, Body = body }) { message.IsBodyHtml = true; smtp.Send(message); } TempData["message"] = "Votre mot de passe est : '" + candidat.Password + "'." + " Vous le trouverez sur votre email aussi."; return(Redirect("Login")); } return(View(candidat)); }
public IEnumerable <SearchModel3> info(int niveau) { GestionConcourDbContext db = new GestionConcourDbContext(); var x = (from c in db.Candidats join a in db.AnneeUniversitaires on c.Cne equals a.Cne join b in db.Baccalaureats on c.Cne equals b.Cne join concour in db.CouncourEcrits on c.Cne equals concour.Cne join d in db.Diplomes on c.Cne equals d.Cne where !db.Corbeilles.Select(g => g.CNE).ToList().Contains(c.Cne) join oral in db.CouncourOrals on c.Cne equals oral.Cne where c.Niveau == niveau select new SearchModel3 { Nom = c.Nom, Prenom = c.Prenom, Sexe = c.Sexe, NoteBac = b.NoteBac, Note1 = a.Semestre1, Note2 = a.Semestre2, Note3 = a.Semestre3, Note4 = a.Semestre4, Note5 = a.Semestre5, Note6 = a.Semestre6, Dossier = c.Num_dossier, Convoque = c.Convoque, Math = concour.NoteMath, Specialite = concour.NoteSpecialite, Matricule = c.Matricule, Email = c.Email, Lieu_Naiss = c.LieuNaissance, Nationalite = c.Nationalite, Adress = c.Adresse, Ville = c.Ville, Type_dip = d.Type, note_Diplome = d.NoteDiplome, Etablissement = d.Etablissement, Ville_dip = d.VilleObtention, Date_inscription = c.DateInscription, Admis = c.Admis, Filiere = db.Filieres.Where(f => f.ID == c.ID).FirstOrDefault().Nom, Cin = c.Cin, Cne = c.Cne, NonConforme = c.Conforme, }).ToList().Select(v => { var fichier = db.Fichiers.Where(f => f.Cne == v.Cne).SingleOrDefault(); var part1 = ""; var part2 = ""; var part3 = ""; if (fichier != null) { if (fichier.nom.Split('|').Length == 1) { part1 = fichier.nom.Split('|')[0]; } else if (fichier.nom.Split('|').Length == 2) { part1 = fichier.nom.Split('|')[0]; part2 = fichier.nom.Split('|')[1]; } else { part1 = fichier.nom.Split('|')[0]; part2 = fichier.nom.Split('|')[1]; part3 = fichier.nom.Split('|')[2]; } } return(new SearchModel3 { Nom = v.Nom, Prenom = v.Prenom, Sexe = v.Sexe, NoteBac = v.NoteBac, Note1 = v.Note1, Note2 = v.Note2, Note3 = v.Note3, Note4 = v.Note4, Note5 = v.Note5, Note6 = v.Note6, Dossier = v.Dossier, Convoque = v.Convoque, Math = v.Math, Specialite = v.Specialite, Matricule = v.Matricule, Email = v.Email, Lieu_Naiss = v.Lieu_Naiss, Nationalite = v.Nationalite, Adress = v.Adress, Ville = v.Ville, Type_dip = v.Type_dip, note_Diplome = v.note_Diplome, Etablissement = v.Etablissement, Ville_dip = v.Ville_dip, Date_inscription = v.Date_inscription, Admis = v.Admis, Filiere = v.Filiere, Cin = v.Cin, Cne = v.Cne, NonConforme = v.NonConforme, Diplome1 = part1, Diplome2 = part2, Diplome3 = part3 }); }).ToList(); return(x); }
public Statistique3AImpl() { Bdd = new GestionConcourDbContext(); }
//Constructor public IndexServiceImp() { db = new GestionConcourDbContext(); db.Configuration.ProxyCreationEnabled = false; }