public void Load_Image() { idTest = 1; Professeur professeur = new Professeur(); string connStr = Utils.GetConn; using (MySqlConnection conn = new MySqlConnection(connStr)) { string sql = "SELECT * FROM Professeur WHERE id = @id"; conn.Open(); using (MySqlCommand cmd = new MySqlCommand(sql, conn)) { cmd.Parameters.Add(new MySqlParameter("@id", idTest)); using (MySqlDataReader dr = cmd.ExecuteReader()) { while (dr.Read()) { professeur.Id = (int)dr["id"]; professeur.Nom = (string)dr["nom"]; professeur.Prenom = (string)dr["prenom"]; professeur.Classe = (int)dr["classe"]; professeur.MotDePasse = (string)dr["motDePasse"]; } } } } Assert.AreEqual(professeur.Id, idTest); Assert.AreEqual(professeur.Nom, "Venezia"); Assert.AreEqual(professeur.Prenom, "Matthieu"); Assert.AreEqual(professeur.Classe, 1); Assert.AreEqual(professeur.MotDePasse, "1234"); Trace.WriteLine("id: " + professeur.Id + " Nom: " + professeur.Nom + " Prenom: " + professeur.Prenom + " Classe: " + professeur.Classe + " MotDePasse: " + professeur.MotDePasse); }
public ActionResult AddProfesseur(string nom, string email, string login, string password, string tel, string nni) { if (nom == null || nom.Equals("") || email == null || email.Equals("") || login == null || login.Equals("") || password == null || password.Equals("") || nni == null || nni.Equals("") || _professeurService.GetUserByLogin(login) != null || _professeurService.GetUserByEmail(email) != null || _professeurService.GetUserByTelephone(tel) != null) { return(RedirectToAction("AddProfesseur", "Administrateur")); } Professeur prof = new Professeur { isActive = 1, Email = email, Login = login, Nom = nom, ProfilePath = "~/Resources/Profiles/avatar.png", Password = CommonService <Administrateur> .Hash(password), Telephone = tel }; prof = _professeurService.Add(prof); if (prof == null) { return(RedirectToAction("AddProfesseur", "Administrateur")); } return(RedirectToAction("Professeurs", "Administrateur")); }
public async Task <IActionResult> put(int professeurId, Professeur model) { try { var Professeur = await _repo.GetProfesseurAsyncById(professeurId, false); if (Professeur == null) { return(NotFound()); } _repo.Update(model); if (await _repo.SaveChangesAsync()) { return(Ok(model)); } } catch (Exception ex) { return(BadRequest($"Erro: {ex.Message}")); } return(BadRequest()); }
public async Task <IActionResult> MdfProf(int id, [Bind("Id_Prof,Nom_Prof,Prenom_Prof,CIN_Prof,Email_Prof,Mdp")] Professeur professeur) { if (id != professeur.Id_Prof) { return(NotFound()); } if (ModelState.IsValid) { try { _db.Update(professeur); await _db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ProfesseurExists(professeur.Id_Prof)) { return(NotFound()); } else { throw; } } return(RedirectToAction("IndexProf")); } return(View(professeur)); }
public async Task <IActionResult> Edit(int id, [Bind("ProfesseurID,NomProf,PrenomProf,HireDate")] Professeur professeur) { if (id != professeur.ProfesseurID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(professeur); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ProfesseurExists(professeur.ProfesseurID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(professeur)); }
public async Task <IActionResult> Edit(string id, [Bind("Domaine,Id_Utilisateur,IdNational,IdUniversitaire,NomPrenom,PhotoProfil,Fichier_Profil,Email,Standarized_Email,Hash_Password,Email_Confirm,Connect")] Professeur professeur) { if (id != professeur.Id_Utilisateur) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(professeur); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ProfesseurExists(professeur.Id_Utilisateur)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(professeur)); }
public Professeur FindProfesseurByMatricule(String matricule) { Professeur professeur = null; String sql = String.Format("select * from where matricule=(0)", matricule); return(professeur); }
public async Task <Professeur> Create(Professeur professeur) { Professeur p = new Professeur { Id = 4, Nom = "Luzolo", Postnom = "Lusembo", Prenom = "Plamedi", Email = "*****@*****.**", TitreFormation = "Informaticien" }; Eleve e = new Eleve { Id = 45, Nom = "Luzolo", Postnom = "Matanu", Prenom = "Hervé", Email = "*****@*****.**", AnneeScolaire = "4e SC" }; Utilisateur u = new Utilisateur { NomUtilisateur = "*****@*****.**", MotDePasse = "jkhfdb", MembreId = p.Id, Discriminator = 'P' }; Context.Set <Utilisateur>().Add(u); Context.Set <Professeur>().Add(p); await Context.SaveChangesAsync(); return(professeur); }
public async Task <IActionResult> PutProfesseur([FromRoute] string id, [FromBody] Professeur professeur) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != professeur.Id_Utilisateur) { return(BadRequest()); } _context.Entry(professeur).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ProfesseurExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> CreateProfesseur([FromBody] long ecoleId, ProfesseurCreateDto professeurCreateDto) { if (professeurCreateDto.name == null) { return(BadRequest()); } Ecole ecole = await _ecoleRepository.GetById(ecoleId); if (ecole == null) { return(NotFound()); } Professeur professeur = Professeur.From(professeurCreateDto); professeur.Ecole = ecole; await _professeurRepository.CreateEntity(professeur); var res = await _ecoleRepository.SaveAsync(); if (!res) { return(BadRequest()); } return(Created("professeur/me", professeur)); }
public async Task <IActionResult> UpdateProfesseur([FromBody] long id, ProfesseurCreateDto professeurCreateDto) { if (professeurCreateDto.name == null) { return(BadRequest()); } Professeur professeur = await _professeurRepository.GetById(id); if (professeur == null) { return(NotFound()); } professeur.Name = professeurCreateDto.name; var res = await _professeurRepository.SaveAsync(); if (!res) { return(BadRequest()); } return(Ok()); }
internal static void fill(Professeur item, MySqlDataReader dr) { item.Id = (int)dr["id"]; item.Nom = (string)dr["nom"]; item.Prenom = (string)dr["prenom"]; item.Classe = (int)dr["classe"]; item.MotDePasse = (string)dr["motDePasse"]; }
public JsonResult Delete(int ID) { Professeur professeur = db.professeurs.Find(ID); db.professeurs.Remove(professeur); db.SaveChanges(); return(Json(0, JsonRequestBehavior.AllowGet)); }
public async Task <IActionResult> IndexMat(string email, Professeur p) { if (HttpContext.Session.GetString("username") == null /*|| HttpContext.Session.GetString("username") != p.Email_Prof*/) { return(View("Login")); } var matiere = await _db.matieres.Include(m => m.professeur).Where(x => x.professeur.Email_Prof == email).ToListAsync(); return(View(matiere)); }
public async Task <ActionResult <Professeur> > Create(Professeur professeur) { Professeur professeur1 = await ProfesseurService.Create(professeur); if (professeur1 == null) { return(BadRequest()); } return(Created("", professeur1)); }
public async Task <IActionResult> IndexSea(int id, Professeur p) { if (HttpContext.Session.GetString("username") == null) { return(View("Login")); } var seance = await _db.seances.Include(s => s.filiere).Include(s => s.matiere).Include(s => s.salle).Where(x => x.Id_Matiere == id).ToListAsync(); return(View(seance)); }
public async Task <IActionResult> IndexPre(int id, Professeur p) { if (HttpContext.Session.GetString("username") == null || HttpContext.Session.GetString("username") != p.Email_Prof) { return(View("Login")); } var presence = await _db.presences.Include(p => p.salle).Where(x => x.Id_Salle == id).ToListAsync(); return(View(presence)); }
public async Task <ActionResult <Professeur> > GetById(int id) { Professeur professeur = await ProfesseurService.GetById(id); if (professeur == null) { return(NotFound()); } return(professeur); }
public static void Insert(string username, string password, string email) { var db = SqliteDB.connect(); var newProfesseur = new Professeur(); newProfesseur.Username = username; newProfesseur.Password = password; newProfesseur.Email = email; db.Insert(newProfesseur); db.Close(); }
public async Task <IActionResult> Create([Bind("Domaine,Id_Utilisateur,IdNational,IdUniversitaire,NomPrenom,PhotoProfil,Fichier_Profil,Email,Standarized_Email,Hash_Password,Email_Confirm,Connect")] Professeur professeur) { if (ModelState.IsValid) { _context.Add(professeur); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(professeur)); }
public async Task <IActionResult> Create([Bind("ProfesseurID,NomProf,PrenomProf,HireDate")] Professeur professeur) { if (ModelState.IsValid) { _context.Add(professeur); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(professeur)); }
public async Task <IActionResult> AjtProf([Bind("Id_Prof,Nom_Prof,Prenom_Prof,CIN_Prof,Email_Prof,Mdp")] Professeur professeur) { if (ModelState.IsValid) { _db.Add(professeur); await _db.SaveChangesAsync(); return(RedirectToAction("IndexProf")); } return(View(professeur)); }
static void Main(string[] args) { Personne s1; Personne p1 = new Etudiant(); Personne p2 = new EtudiantDiplômé(); Etudiant e1 = new EtudiantDiplômé(); Personne t2 = new Professeur(); s1 = p1; p1 = e1; e1 = (Etudiant)s1; }
public async Task <IActionResult> PostProfesseur([FromBody] Professeur professeur) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.Professeur.Add(professeur); await _context.SaveChangesAsync(); return(CreatedAtAction("GetProfesseur", new { id = professeur.Id_Utilisateur }, professeur)); }
public ActionResult ChangePassword(string oldpass, string newpass, string renewpass) { Professeur user = (Professeur)Session["user"]; if (!user.Password.Equals(_utilities.Hash("iscae" + oldpass)) || !renewpass.Equals(newpass)) { return(RedirectToAction("UserProfile")); } user.Password = _utilities.Hash("iscae" + newpass); user = _professeurService.Edit(user); return(RedirectToAction("UserProfile")); }
public async Task <IActionResult> GetProfesseur(long id) { Professeur professeur = await _professeurRepository.GetById(id); if (professeur == null) { return(NotFound()); } var res = _mapper.Map <ProfesseurResponseDto>(professeur); return(Ok(res)); }
public JsonResult Update(Professeur professeur) { Professeur prof = db.professeurs.Find(professeur.Id); prof.Prenom = professeur.Prenom; prof.Nom = professeur.Nom; prof.Email = professeur.Email; prof.Telephone = professeur.Telephone; prof.Adresse = professeur.Adresse; prof.Cni = professeur.Cni; prof.PrixHeure = professeur.PrixHeure; db.SaveChanges(); return(Json(1, JsonRequestBehavior.AllowGet)); }
// GET: Professeur public ActionResult Index() { Professeur user = (Professeur)Session["user"]; // Notifications List <Notification> notifications = _notificationService.GetUnreadNotifications(user.ProfesseurId).ToList(); int notificationCount = notifications.Count(); List <Etudiant> etudiants = new List <Etudiant>(); // Documents List <DocumentOfficiel> mesDocuments = _documentOfficielService.GetDocumentsByUser(user.ProfesseurId, 1, 10).ToList(); List <DocumentNonOfficiel> documents = new List <DocumentNonOfficiel>(); List <Module> modules = new List <Module>(); List <ProfesseurModule> professeurModules = _professeurModuleService.GetModulesByProfesseur(user.ProfesseurId).ToList(); foreach (ProfesseurModule module in professeurModules) { modules.Add(_moduleService.Get(module.ModuleId)); documents.AddRange(_documentNonOfficielService.GetDocumentByModule(module.ModuleId)); } documents = documents.OrderByDescending(o => o.DocumentNonOfficielId).Take(10).ToList(); // Messages List <Message> messages = _messageService.GetMessagesByProfesseur(user.ProfesseurId, 1, 5).ToList(); // Specialites List <Specialite> specialites = new List <Specialite>(); // Annonces List <Annonce> annonces = _annonceService.GetAll().OrderByDescending(o => o.AnnonceId).Take(5).ToList(); //Etudiants var specialiteWithNiveau = _professeurService.GetSpecialiteWithNiveau(user.ProfesseurId); foreach (int specialite in specialiteWithNiveau.Keys) { specialites.Add(_specialiteService.Get(specialite)); foreach (int niveau in specialiteWithNiveau[specialite]) { etudiants.AddRange(_etudiantService.GetEtudiantsBySpecialite(specialite, niveau).ToList()); } } // Model Session["notifications"] = notifications; Session["notificationCount"] = notificationCount; ViewBag.documents = documents; ViewBag.messages = messages; ViewBag.annonces = annonces; ViewBag.specialites = specialites; ViewBag.modules = modules; ViewBag.etudiants = etudiants; return(View(mesDocuments)); }
public async Task <bool> Delete(int id) { Professeur Professeur = await Context.Professeurs.FindAsync(id); if (Professeur == null) { return(false); } Context.Professeurs.Remove(Professeur); await Context.SaveChangesAsync(); return(true); }
public async Task <IActionResult> OnGetAsync(string id) { if (id == null) { return(NotFound()); } Professeur = await _context.Professeur.FirstOrDefaultAsync(m => m.CIN == id); if (Professeur == null) { return(NotFound()); } return(Page()); }