Exemple #1
0
        public ActionResult Ajouter([Bind(Include =
                                              "DtDisponibilite,LbDisponibilite,Remuneration,Mobilite,InfCom," +
                                              "TypAction,TypPriorite,TypOrigine,TypStatut," +
                                              "MCEntreprise,MCFonctionnel,MCTechnique," +
                                              "DtCreation,CreePar,DtModification,ModifiePar")] Candidat candidat,
                                    [Bind(Include = "Civilite,Prenom,Nom,TelMobile,email," +
                                                    "Adresse,AdresseComplement,CodePostal,Ville,Pays")] Humain humain,
                                    [Bind(Include = "TypTdb")] Role roleCandidat)
        {
            int newHumain = db.Humain.Select(h => h.CdHumain).ToList().Last() + 1;

            candidat.CdHumain       = newHumain;
            roleCandidat.CdHumain   = newHumain;
            roleCandidat.CdCandidat = db.Candidat.Select(c => c.CdCandidat).ToList().Last() + 1;
            //role.CdRole = db.Role.Select(r => r.CdRole).ToList().Last() + 1;
            if (ModelState.IsValid)
            {
                db.Humain.Add(humain);
                db.SaveChanges();

                db.Candidat.Add(candidat);
                db.SaveChanges();

                db.Role.Add(roleCandidat);
                db.SaveChanges();
                return(RedirectToAction("fiche", "Candidat", new { id = candidat.CdCandidat }));
            }
            return(RedirectToAction("Vue"));
        }
Exemple #2
0
        private Personnage CreerHumain()
        {
            Humain newHumain = new Humain();

            CreerHumainDonnées(newHumain);
            Animated(x, y++, 5, $"Bienvenue {newHumain.Nom}");
            Continue(x, y, 5);
            return(newHumain);
        }
        private void BtnRamasserClick(object sender, RoutedEventArgs e) // Rammase le troupeau et le remet à 0
        {
            // Supprimer le contenu du troupeau et ajouter à l'étable du joueur qui vient de ramasser
            // Doit faire appel à 2 méthodes:
            // se référer aux classes (et voir le diagramme UML)
            // exemple: imaginer que cette ligne a été écrite à sa place (création de la partie)
            Humain romain = new Humain();

            // j'appelle la méthode ramasser
            romain.ramasser();

            // Problème: cette fonction doit utiliser le bon joueur

            MessageBox.Show("Vous avez rammassé le troupeau !");
        }
Exemple #4
0
        public ActionResult fiche([Bind(Include =
                                            "CdHumain,CdCandidat,DtDisponibilite,LbDisponibilite,Remuneration,Mobilite,InfCom," +
                                            "TypAction,TypPriorite,TypOrigine,TypStatut," +
                                            "MCEntreprise,MCFonctionnel,MCTechnique," +
                                            "DtCreation,CreePar,DtModification,ModifiePar")] Candidat candidat,
                                  [Bind(Include = "CdHumain,Civilite,Prenom,Nom,TelMobile,email," +
                                                  "Adresse,AdresseComplement,CodePostal,Ville,Pays")] Humain humain,
                                  [Bind(Include = "CdRole,TypTdb")] Role roleCandidat, ICollection <EvenementCandidat> EvenementCandidat)
        {
            roleCandidat.CdHumain   = humain.CdHumain;
            roleCandidat.CdCandidat = candidat.CdCandidat;
            roleCandidat.CdRole     = db.Role
                                      .Where(r => r.CdHumain == humain.CdHumain)
                                      .Select(r => r.CdRole).ToList().First();
            if (ModelState.IsValid)
            {
                db.Entry(humain).State = EntityState.Modified;
                db.SaveChanges();
                db.Entry(roleCandidat).State = EntityState.Modified;
                db.SaveChanges();
                if (EvenementCandidat != null)
                {
                    foreach (var evt in EvenementCandidat)
                    {
                        var temp = db.EvenementCandidat.Where(e => e.CdEvenement == evt.CdEvenement).First();
                        mapEvenememtCandidat(temp, evt);
                    }
                    db.SaveChanges();
                }
                db.Entry(candidat).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Vue"));
            }

            return(RedirectToAction("fiche", "Candidat", new { id = candidat.CdCandidat }));
        }
Exemple #5
0
        public static void Main(string[] args)
        {
            /*************************
            *   1- D E L E G A T E S
            *   return type is covariant and the parameters are contravariant
            *************************/

            Animal a = new Bird();

            //a- return type example
            ReturnAnimalDelegate da = GetAnimal;
            ReturnAnimalDelegate db = GetBird;

            a = db();

            //The other way (reverse asignement) around doesn't work
            ReturnBirdDelegate dbb = GetAnimal;  //Failed otherwise  dbb().Fly() should work,

            //failed the same way as
            Bird b = new Animal();

            //b- the parameters example
            TakeBirdDelegate   tb = Fly;
            TakeAnimalDelegate ta = Eat;

            tb = Eat;

            //In delegate reverse asignement is contravariant in argument type (success in passing the Bird instead of animal)
            ta(new Bird());

            //(reverse asignement) failed
            tb(new Animal()); ta = Fly;

            /**************************************S U M M A R Y *********************************************
             * for delegates the return type is covariant and the parameters are contravariant,
             * the delegates are the only construct in C# that supports Covariance & Contravariance
             *********************************************************************************************/

            /*************************
            *   2- A R R A Y S
            *   Array with refrence type are also covariants
            *************************/
            //assignment is preserved
            Animal[] animals = new Bird[10];
            animals[0] = new Humain();  //compilers doesn't complain but runtime Exception (ArrayTypeMismatchException)


            /*************************
            *   3- G E N E R I C S
            *
            *************************/
            IProcess <Animal> animalProcessor = new AnimalProcessor <Animal> ();
            IProcess <Bird>   birdProcessor   = new AnimalProcessor <Bird> ();

            //covariance makes sense, since birdProcessor.Process() return bird which is an animal
            Animal animal = birdProcessor.Process();

            //Cannot implicitly convert type 'IProcess<Bird>' to 'IProcess<Animal>'. An explicit conversion exists (are you missing a cast?
            //even the compiler gives an error, since .net 4.0 we could make it covariant by adding an out keyword to the interface
            animalProcessor = birdProcessor;

            //public interface IEnumerable<out T> : IEnumerable
            IEnumerable <Animal> animalList = new List <Bird> ();

            //generic contravariance
            IZoo <Animal> animalZoo = new Zoo <Animal>();

            animalZoo.add(new Animal());

            //we could also a
            animalZoo.add(new Bird());

            IZoo <Bird> birdZoo = new Zoo <Bird>();

            birdZoo.add(new Bird());

            //generic contravariance
            birdZoo = animalZoo;
            birdZoo = new Zoo <Animal>();

            //doesn't works
            birdZoo = new Zoo <Humain>();

            /*****************************************************************************
             * public interface IComparer<in T> :
             * makes senses if we want to compare not only birds by any abstract
             * animal with birds
             ******************************************************************************/
            //Also the same goes for generics delegates func and action
        }