public void Delete(Participation part) { var query = Session.CreateQuery("delete from Participation where Id = :Id"); query.SetParameter("Id", part.ID); query.ExecuteUpdate(); }
public Coureur GetCoureurFromParti(Participation parti) { List <Coureur> query = Session.Query <Coureur>().Where((u) => u.ID == parti.Participant.ID).ToList(); Coureur coureur = (query.Count == 0) ? null : query[0]; return(coureur); }
public static Participation GetParticipation(int _Id) { Participation participation = new Participation(); try { DbConnect db = new DbConnect(); db.Command.CommandText = "GetOneParticipation"; db.Command.Parameters.AddWithValue("_id", _Id); MySqlDataReader reader = db.Command.ExecuteReader(); reader.Read(); participation.Id = (int)reader[0]; participation._Employe = new Employe(); participation._Employe = Employe.GetEmploye((int)reader[1]); participation._Projet = new Projet(); participation._Projet = Projet.GetProjet((string)reader[2]); participation.Fonction = (string)reader[3]; db.Connection.Close(); } catch { } return(participation); }
public static List <Participation> Participations() { List <Participation> AllParticipation = new List <Participation>(); try { DbConnect db = new DbConnect(); db.Command.CommandText = "GetAllParticipations"; MySqlDataReader reader = db.Command.ExecuteReader(); while (reader.Read()) { Participation p = new Participation() { Id = (int)reader[0], _Employe = new Employe() }; p._Employe = Employe.GetEmploye((int)reader[1]); p._Projet = new Projet(); p._Projet = Projet.GetProjet((string)reader[2]); p.Fonction = (string)reader[3]; AllParticipation.Add(p); } db.Connection.Close(); } catch { } return(AllParticipation); }
/// <summary> /// This function convert the data give by ImportCsvBrut to Participation and transfer it to db /// </summary> /// <param name="dico"></param> /// <param name="course"></param> public static void Import(Dictionary <string, List <string> > dico, Course course) { ParticipationCSVToDB.CSVContainsRightColumnLabel(dico); ParticipationCSVToDB.CSVContainsColumnWithSameNumberOfElement(dico); Participation part; Coureur coureur; // Save data in db IParticipationRepository repo = new ParticipationRepository(); for (int i = 0; i < dico[dico.Keys.First()].Count; i++) { coureur = new Coureur(dico["nom"][i] , dico["prenom"][i] , dico["licence"][i] , dico["courriel"][i] , dico["sexe"][i] , Convert.ToDateTime(dico["annee_naissance"][i])); part = new Participation(); part.Course = course; part.Participant = coureur; part.NumDossard = Convert.ToInt32(dico["dossard"][i]); if (dico.Keys.Contains("temps")) { part.Temps = Convert.ToDouble(dico["temps"][i].Replace('.', ',')); } repo.Save(part); } }
public void Save(Participation part) { if (!Exist(part)) { Session.SaveOrUpdate(part); Session.Flush(); } }
public static void InsertParticipation(Participation particiation) { try { DbConnect db = new DbConnect(); db.Command.CommandText = "InsertParticipation"; db.Command.Parameters.AddWithValue("_Id", particiation.Id); db.Command.Parameters.AddWithValue("_Matr", particiation._Employe.Matr); db.Command.Parameters.AddWithValue("_CodeP", particiation._Projet.CodeP); db.Command.Parameters.AddWithValue("_Fonction", particiation.Fonction); db.Command.ExecuteNonQuery(); db.Connection.Close(); } catch { } }
public ParticipationRepoTest() { ParticipationCollection = new List <Participation>(); Coureur coureur1 = new Coureur("coureur1", "1", "XXXXXXXXX", "*****@*****.**", "X", DateTime.Today); Coureur coureur2 = new Coureur("coureur2", "2", "XXXXXXXXX", "*****@*****.**", "X", DateTime.Today); Coureur coureur3 = new Coureur("coureur3", "3", "XXXXXXXXX", "*****@*****.**", "X", DateTime.Today); Course course1 = new Course("course1", 1); Course course2 = new Course("course2", 2); Participation participation1 = new Participation(coureur1, course1, 042, 10); ParticipationCollection.Add(participation1); Participation participation2 = new Participation(coureur2, course1, 240, 12); ParticipationCollection.Add(participation2); Participation participation3 = new Participation(coureur1, course2, 420, 110); ParticipationCollection.Add(participation3); }
public void Save(Participation participation) { ParticipationCollection.Add(participation); }
public bool Exist(Participation part) { throw new NotImplementedException(); }
public void Delete(Participation part) { throw new NotImplementedException(); }
public bool Exist(Participation part) { return(Session.Query <Participation>().Any(c => c.NumDossard == part.NumDossard && c.Course == part.Course)); }
public Coureur GetCoureurFromParti(Participation parti) { throw new NotImplementedException(); }
public void Remove(Participation participation) { Session.Delete(participation); Session.Flush(); }
public void Save(Participation participation) { Session.SaveOrUpdate(participation); Session.Flush(); }