public DataSet Bulletins() { List <GridViewModel> list = new List <GridViewModel>(); foreach (Etudiant e in context.Etudiants) { float somme = 0; int sommecoef = 0; var query = from n in context.Notes where n.Idetudiant == e.Id select n; List <Note> notes = query.ToList <Note>(); foreach (Note n in notes) { Matiere matiere = (from m in context.Matieres where m.Id == n.Idmatiere select m).First <Matiere>(); somme += n.NoteObtenue * matiere.Coef; sommecoef += matiere.Coef; } float noteFinal = somme / sommecoef; list.Add(new GridViewModel() { ID = e.Id, nom = e.Nom, prenom = e.Prenom, note = noteFinal }); } return(Helper.ToDataSet(list)); }
public void AjouterMatiere(int Id, int Coef, string Libelle) { Matiere Matiere = new Matiere() { Id = Id, Coef = Coef, Libelle = Libelle }; context.Matieres.Add(Matiere); context.SaveChanges(); }