public FormulaireTrancheAgeVM() { this._repoTrancheAge = new Repository <TrancheAge>(this._context); this.UCParentCode = CodesUC.ConsultationTranchesAge; this.IsEditMode = false; this.CurrentTrancheAge = new TrancheAge(); }
/// <summary> /// Constructeur pour le mode édition. On doit passer par l'id pour récupérer la tranche d'âge car on a changé de contexte. /// </summary> /// <param name="idAdherent">ID de la tranche d'âge à éditer</param> public FormulaireTrancheAgeVM(Guid idTrancheAge) { this._repoTrancheAge = new Repository <TrancheAge>(this._context); this.UCParentCode = CodesUC.ConsultationTranchesAge; this.IsEditMode = true; this.CurrentTrancheAge = this._repoTrancheAge.GetByKey(idTrancheAge); }
public async Task <ActionResult> DeleteConfirmed(int id) { TrancheAge trancheAge = await db.TrancheAge.FindAsync(id); db.TrancheAge.Remove(trancheAge); await db.SaveChangesAsync(); return(RedirectToAction("Index")); }
public async Task <ActionResult> Edit([Bind(Include = "Id,Libelle,AgeMin,AgeMax")] TrancheAge trancheAge) { if (ModelState.IsValid) { db.Entry(trancheAge).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(trancheAge)); }
static public ArrayList lesJouets() { ArrayList jouets = new ArrayList(); /* [type]JouetsBDD=connexion("SELECT * FROM jouet ORDER BY id") */ CatalogueJouetPoulmane.Categorie categ = new Categorie(1, "test"); CatalogueJouetPoulmane.TrancheAge tranche = new TrancheAge(1, 5, 8); CatalogueJouetPoulmane.Jouet jouet = new CatalogueJouetPoulmane.Jouet(1, "bull", categ, tranche); jouets.Add(jouet); Connection.Close(); return(jouets); }
public async Task <ActionResult> Create([Bind(Include = "Id,Libelle,AgeMin,AgeMax")] TrancheAge trancheAge) { if (ModelState.IsValid) { db.TrancheAge.Add(trancheAge); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(trancheAge)); }
public static ArrayList lesJouets() { ArrayList jouets=new ArrayList(); /* [type]JouetsBDD=connexion("SELECT * FROM jouet ORDER BY id") */ CatalogueJouetPoulmane.Categorie categ= new Categorie(1,"test"); CatalogueJouetPoulmane.TrancheAge tranche= new TrancheAge(1,5,8); CatalogueJouetPoulmane.Jouet jouet = new CatalogueJouetPoulmane.Jouet(1,"bull",categ,tranche); jouets.Add(jouet); Connection.Close(); return jouets; }
// GET: TrancheAges/Details/5 public async Task <ActionResult> Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } TrancheAge trancheAge = await db.TrancheAge.FindAsync(id); if (trancheAge == null) { return(HttpNotFound()); } return(View(trancheAge)); }
// GET: TrancheAges/Edit/5 public async Task <ActionResult> Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } TrancheAge trancheAge = await db.TrancheAge.FindAsync(id); if (trancheAge == null) { return(HttpNotFound()); } TrancheAgeEM trancheAgeAmodifier = new TrancheAgeEM(); var config = new MapperConfiguration(cfg => cfg.CreateMap <TrancheAge, TrancheAgeEM>()); var mapper = new Mapper(config); trancheAgeAmodifier = mapper.Map <TrancheAgeEM>(trancheAge); return(View(trancheAgeAmodifier)); }
public List <Jouet> findByAge(int pAge) { List <Jouet> desJouets = new List <Jouet>(); SqlDataReader resultat = executerSQL("Select numero,libelle,idCategorie,idTrancheAge From jouet join trancheAge on jouet.idTrancheAge=trancheAge.code where ageMin<=" + pAge + " and ageMax>=" + pAge); while (resultat.Read()) { int numero = (int)resultat["numero"]; string libelle = (string)resultat["libelle"]; int idCategorie = (int)resultat["idCategorie"]; int idTrancheAge = (int)resultat["idTrancheAge"]; Categorie uneCategorie = (new CategorieDAO()).find(idCategorie); TrancheAge uneTranche = (new TrancheAgeDAO()).find(idTrancheAge); desJouets.Add(new Jouet(numero, libelle, uneCategorie, uneTranche)); } resultat.Close(); return(desJouets); }
/// <summary> /// Recupère tout les jouets présent dans la base de données /// </summary> /// <returns></returns> public override List <Jouet> findAll() { List <Jouet> jouets = new List <Jouet>(); Categorie laCategorie; TrancheAge laTranche; Jouet unJouet; int i = 0; SqlDataReader resultat = this.executerSQL("SELECT c.libelle as catLib,j.libelle as jouetLib,t.ageMin as ageMin,t.ageMax as ageMax FROM jouet j join Categorie c on c.idCategorie=j.idCategorie join TrancheAge t on j.idTrancheAge=t.idTrancheAge ORDER BY j.libelle"); while (resultat.Read()) { laCategorie = new Categorie(i, ((string)resultat["catLib"])); laTranche = new TrancheAge(i, ((int)resultat["ageMin"]), ((int)resultat["ageMax"])); unJouet = new Jouet(i, ((string)resultat["jouetLib"]), laCategorie, laTranche); jouets.Add(unJouet); i++; } resultat.Close(); return(jouets); }
/// <summary> /// Recupère tout les jouets présent dans la base de données /// </summary> /// <returns></returns> public override ArrayList findAll() { ArrayList jouets = new ArrayList(); CatalogueJouetPoulmane.Categorie laCategorie; CatalogueJouetPoulmane.TrancheAge laTranche; CatalogueJouetPoulmane.Jouet unJouet; int i = 0; SqlDataReader resultat = this.connexion("SELECT c.libelle as catLib,j.libelle as jouetLib,t.ageMin as ageMin,t.ageMax as ageMax FROM jouet j join Categorie c on c.idCategorie=j.idCategorie join TrancheAge t on j.idTrancheAge=t.idTrancheAge ORDER BY j.libelle"); while (resultat.Read()) { laCategorie = new Categorie(i, ((string)resultat["catLib"])); laTranche = new TrancheAge(i, ((int)resultat["ageMin"]), ((int)resultat["ageMax"])); unJouet = new Jouet(i, ((string)resultat["jouetLib"]), laCategorie, laTranche); jouets.Add(unJouet); i++; } this.closeConnection(); return(jouets); }