private int FormatAndSetFormationDate(CtrlAttributesEnregistrer attEnregistrer, Formation formation1, int param_renseign) { DateTime date = new DateTime(attEnregistrer.param_f_formation1_date_debut_annee.Value, attEnregistrer.param_f_formation1_date_debut_mois.Value, 1); formation1.frmDateDebut=date; param_renseign++; return param_renseign; }
public static void Insert(Formation formation) { // Warning : fake for exercise long newId = Database.formationTable.Count; formation.setFrmId(newId); Database.formationTable.Add(newId, formation); logger.Info("inserting Formation :" + formation.ToString()); }
public static void Insert(Formation formation) { using (var db = new Database()) { db.formationTable.Add(formation); db.SaveChanges(); } logger.Info("inserting Formation :" + formation.ToString()); }
public static void Update(Formation formation) { // Warning : fake for exercise if (Database.formationTable[formation.getFrmId()] == null) { throw new Exception("No ROW in table FORMATION with given Identifier : " + formation.getFrmId()); } Database.formationTable.Add(formation.getFrmId(), formation); logger.Info("Updating Formation :" + formation.ToString()); }
public static void Update(Formation formation) { using (var db = new Database()) { var f = db.formationTable.Find(formation.frmId); if (f == null) { throw new Exception("No ROW in table FORMATION with given Identifier : " + formation.frmId); } db.formationTable.Attach(formation); db.SaveChanges(); } logger.Info("Updating Formation :" + formation.ToString()); }
public void DoEnregistrer(SessionContainer scc, ControllerBaseAttributes attributes) { CtrlAttributesEnregistrer attEnregistrer = (CtrlAttributesEnregistrer) attributes; attributes.enableRedirectParam = true; Internaute internaute = scc.Internaute; CV cv = new CV(); // On r�cup�re le Pourcentage d'origine CVFactory cvFactory = new CVFactory(); cv = cvFactory.GetTableauBord(internaute.IntId); // On cr� un nouveau pour la mise � jour cv = new CV(); cv.IntId = internaute.IntId; // poucentage pour ajout Formation formation1 = new Formation(); formation1.intId=internaute.IntId; int param_renseign = 0; /* Formation 1 */ if (HasStartingMonthAndYear(attEnregistrer)) { param_renseign = FormatAndSetFormationDate(attEnregistrer, formation1, param_renseign); } if (attEnregistrer.param_f_formation1_date_fin_mois != null && attEnregistrer.param_f_formation1_date_fin_annee != null) { DateTime date = new DateTime(attEnregistrer.param_f_formation1_date_fin_annee.Value, attEnregistrer.param_f_formation1_date_fin_mois.Value, 1); formation1.frmDateFin = date; param_renseign++; } if (attEnregistrer.param_f_formation1_etablissement != null) { formation1.frmEcole = attEnregistrer.param_f_formation1_etablissement; param_renseign++; } if (attEnregistrer.param_f_formation1_lieu != null) { formation1.frmLieu=attEnregistrer.param_f_formation1_lieu; param_renseign++; } if (attEnregistrer.param_f_formation1_diplome != null) { formation1.frmDiplome=attEnregistrer.param_f_formation1_diplome; param_renseign++; } if (attEnregistrer.param_f_formation1_obtenu != null) { formation1.frmObtenu=attEnregistrer.param_f_formation1_obtenu.Value; param_renseign++; } if (attEnregistrer.param_f_formation1_specialisation != null) { formation1.frmSpecialite=attEnregistrer.param_f_formation1_specialisation; param_renseign++; } if (attEnregistrer.param_f_formation1_tfo_code != null) { formation1.tfoCode=attEnregistrer.param_f_formation1_tfo_code.Value; param_renseign++; } if (param_renseign > 0) { if (attEnregistrer.param_f_formation1_frmid == null || attEnregistrer.param_f_formation1_frmid == null) { FormationFactory.Insert(formation1); } else { formation1.frmId=attEnregistrer.param_f_formation1_frmid.Value; FormationFactory.Update(formation1); } } int pourcent = FormationFactory.GetPourcent(internaute.IntId); if (attEnregistrer.param_f_niveau_formation != null) { cv.nivCode = (attEnregistrer.param_f_niveau_formation.Value); pourcent = pourcent + 5; } cv.SetCuvPourcentFormation(pourcent); cvFactory.InsertFormation(cv); }