Esempio n. 1
0
        public async Task <IHttpActionResult> PutChapitre(int id, Chapitre chapitre)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != chapitre.ChapitreID)
            {
                return(BadRequest());
            }

            db.Entry(chapitre).State = EntityState.Modified;

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ChapitreExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public override Guid AjouterChapitre(Guid idMedia, string description, string debut, string fin)
        {
            Guid idChapitre = Guid.NewGuid();

            using (SQLCompactContext context = GetContext())
            {
                // TODO : Deporter ce test dans la couche Models
                if (!context.Chapitre.Any(c => c.Debut == debut && c.Fin == fin && c.Description == description))
                {
                    Chapitre newChapitre = new Chapitre
                    {
                        ID_Chapitre = idChapitre,
                        Debut       = debut,
                        Fin         = fin,
                        Description = description,
                        FK_ID_Media = idMedia
                    };

                    context.Chapitre.AddObject(newChapitre);
                    context.SaveChanges();

                    return(idChapitre);
                }
            }

            return(Guid.Empty);
        }
Esempio n. 3
0
        public void OnNavigateTo(IDictionary <string, object> param)
        {
            Chapitre chap = (Chapitre)param["niveaux"];

            _facade     = (Facade)param["facade"];
            NiveauxJeux = chap.Niveaux;
        }
Esempio n. 4
0
        public async Task <IHttpActionResult> GetChapitre(int id)
        {
            Chapitre chapitre = await db.Chapitres.FindAsync(id);

            if (chapitre == null)
            {
                return(NotFound());
            }

            return(Ok(chapitre));
        }
Esempio n. 5
0
        public async Task <IHttpActionResult> PostChapitre(Chapitre chapitre)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.Chapitres.Add(chapitre);
            await db.SaveChangesAsync();

            return(CreatedAtRoute("DefaultApi", new { id = chapitre.ChapitreID }, chapitre));
        }
Esempio n. 6
0
        public async Task <IHttpActionResult> DeleteChapitre(int id)
        {
            Chapitre chapitre = await db.Chapitres.FindAsync(id);

            if (chapitre == null)
            {
                return(NotFound());
            }

            db.Chapitres.Remove(chapitre);
            await db.SaveChangesAsync();

            return(Ok(chapitre));
        }
Esempio n. 7
0
        public async Task <bool> DefaultLevels()
        {
            List <Chapitre> chapitres = new List <Chapitre>();
            Chapitre        chap;
            string          nom        = "Chapitre 1";
            List <Niveau>   lesNiveaux = new List <Niveau>();



            lesNiveaux.Add(new NiveauJeux2D(
                               "1 - Carré",
                               new List <Instruction> {
                new InstructionSimple("Tourner 90°", new Etat(90), 1),
                new InstructionSimple("Avancer", new Etat(new Point2D(1.0, 0.0)), 1)
            },
                               7,
                               12,
                               false,
                               new Forme(new List <IVecteur>
            {
                new Vecteur2(new Point2D(0.0, 0.0), new Point2D(1.0, 0.0)),
                new Vecteur2(new Point2D(1.0, 0.0), new Point2D(1.0, 1.0)),
                new Vecteur2(new Point2D(1.0, 1.0), new Point2D(0.0, 1.0)),
                new Vecteur2(new Point2D(0.0, 1.0), new Point2D(0.0, 0.0))
            })
                               ));

            lesNiveaux.Add(new NiveauJeux2D(
                               "3 - Triangle",
                               new List <Instruction> {
                new InstructionSimple("Tourner 90°", new Etat(90), 1),
                new InstructionSimple("Tourner 45°", new Etat(45), 1),
                new InstructionSimple("Avancer", new Etat(new Point2D(1.0, 0.0)), 1)
            },
                               7,
                               12,
                               false,
                               new Forme(new List <IVecteur>
            {
                new Vecteur2(new Point2D(0.0, 0.0), new Point2D(1.0, 0.0)),
                new Vecteur2(new Point2D(1.0, 0.0), new Point2D(1.0, 1.0)),
                new Vecteur2(new Point2D(1.0, 1.0), new Point2D(0.0, 0.0)),
            })
                               ));

            chap = new Chapitre(nom, lesNiveaux);
            chapitres.Add(chap);
            return(await SaveChapitres(chapitres));
        }