コード例 #1
0
        public async Task <IActionResult> PutFestival_Artiste(int id, Festival_Artiste festival_Artiste)
        {
            if (id != festival_Artiste.Id)
            {
                return(BadRequest());
            }

            _context.Entry(festival_Artiste).State = EntityState.Modified;

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

            return(NoContent());
        }
コード例 #2
0
        public async Task <ActionResult <Festival_Artiste> > PostFestival_Artiste(Festival_Artiste festival_Artiste)
        {
            _context.Festival_Artiste.Add(festival_Artiste);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetFestival_Artiste", new { id = festival_Artiste.Id }, festival_Artiste));
        }
コード例 #3
0
        public List <Festival_Artiste> List_Festival_Artiste_Jour(int JourId)
        {
            List <Festival_Artiste> list_Scene = new List <Festival_Artiste>();

            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                string     sqlQuery = "Select * from dbo.Festival_Artiste where JourId = " + JourId;
                SqlCommand command  = new SqlCommand(sqlQuery, connection);
                connection.Open();
                SqlDataReader reader = command.ExecuteReader();

                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        Festival_Artiste festival_Artiste = new Festival_Artiste();

                        festival_Artiste.Id         = reader.GetInt32(0);
                        festival_Artiste.FestivalId = reader.GetInt32(1);
                        festival_Artiste.ArtisteId  = reader.GetInt32(2);
                        festival_Artiste.SceneId    = reader.GetInt32(3);
                        festival_Artiste.JourId     = reader.GetInt32(4);
                        festival_Artiste.HeureDebut = reader.GetDateTime(5);
                        festival_Artiste.HeureFin   = reader.GetDateTime(6);

                        list_Scene.Add(festival_Artiste);
                    }
                }
            }

            return(list_Scene);
        }
コード例 #4
0
        public List <Festival_Artiste> list_Festival_Artiste(int IdS, int IdA)
        {
            List <Festival_Artiste> list = new List <Festival_Artiste>();

            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                string sqlQuery = "Select Festival_Artiste.Id, Festival_Artiste.ArtisteId, Festival_Artiste.FestivalId" +
                                  "Festival_Artiste.JourId, Festival_Artiste.SceneId from dbo.Festival_Artiste " +
                                  "inner join Artiste on Festival_Artiste.ArtisteId = Artiste.IdA " +
                                  "inner join Style.Id = Artiste.StyleId where Artiste.IdA = " + IdA +
                                  " and Style.Id = " + IdS;

                SqlCommand command = new SqlCommand(sqlQuery, connection);
                connection.Open();
                SqlDataReader reader = command.ExecuteReader();

                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        Festival_Artiste festival_Artiste = new Festival_Artiste();

                        festival_Artiste.Id         = reader.GetInt32(0);
                        festival_Artiste.ArtisteId  = reader.GetInt32(2);
                        festival_Artiste.FestivalId = reader.GetInt32(1);
                        festival_Artiste.JourId     = reader.GetInt32(4);
                        festival_Artiste.SceneId    = reader.GetInt32(3);

                        list.Add(festival_Artiste);
                    }
                }
            }

            return(list);
        }
コード例 #5
0
        public IActionResult Edit(Festival_Artiste fa, TimeSpan HeureDebut, TimeSpan HeureFin)
        {
            if (HttpContext.Session.GetInt32("ido") == null)
            {
                return(null);
            }
            Organisateur organisateur = API.Instance.GetOrganisateurAsync((int)HttpContext.Session.GetInt32("ido")).Result;
            Festival     festival     = API.Instance.GetFestivalAsync(organisateur.FestivalId).Result;

            if (festival == null)
            {
                return(null);
            }
            Jour jour = API.Instance.GetJourAsync(fa.JourId).Result;

            fa.HeureDebut = jour.Date_jour.Date + HeureDebut;
            fa.HeureFin   = jour.Date_jour.Date + HeureFin;


            IEnumerable <Festival_Artiste> fas = API.Instance.GetFestival_ArtistesAsync().Result.Where(f => f.SceneId == fa.SceneId);

            fas = API.Instance.GetFestival_ArtistesAsync().Result.Where(f => f.ArtisteId == fa.ArtisteId && f.JourId == fa.JourId);

            if (fas.Count() != 0)
            {
                ModelState.AddModelError("error", "Cet artiste a déjà été programmé pour ce jour");
                return(Edit(fa.Id));
            }

            if (fa.HeureDebut > fa.HeureFin)
            {
                ModelState.AddModelError("error", "Heure de début est plus grande que l'heure de fin !!!");
                return(Edit(fa.Id));
            }
            foreach (var item in fas)
            {
                if ((item.HeureDebut > fa.HeureDebut && item.HeureDebut < fa.HeureFin) || (item.HeureFin > fa.HeureDebut && item.HeureFin < fa.HeureFin))
                {
                    ModelState.AddModelError("error", "Ce créneau est déjà pris pour cette scène !!!");
                    return(Edit(fa.Id));
                }
            }

            fas = API.Instance.GetFestival_ArtistesAsync().Result.Where(f => f.ArtisteId == fa.ArtisteId);
            foreach (var item in fas)
            {
                if ((item.HeureDebut > fa.HeureDebut && item.HeureDebut < fa.HeureFin) || (item.HeureFin > fa.HeureDebut && item.HeureFin < fa.HeureFin))
                {
                    ModelState.AddModelError("error", "Ce créneau est déjà pris pour cet artiste !!!");
                    return(Edit(fa.Id));
                }
            }

            var URI = API.Instance.ModifFestival_ArtisteAsync(fa);

            return(RedirectToAction(nameof(Index)));

            //ViewBag.liste_pays= countries ;
        }
コード例 #6
0
ファイル: API.cs プロジェクト: GastonMAPANGOU/FestivalAPI
        public async Task <Festival_Artiste> GetFestival_ArtisteAsync(int?id)
        {
            Festival_Artiste    festival_Artiste = null;
            HttpResponseMessage response         = client.GetAsync("api/festival_Artistes/" + id).Result;

            if (response.IsSuccessStatusCode)
            {
                var resp = await response.Content.ReadAsStringAsync();

                festival_Artiste = JsonConvert.DeserializeObject <Festival_Artiste>(resp);
            }
            return(festival_Artiste);
        }
コード例 #7
0
ファイル: API.cs プロジェクト: GastonMAPANGOU/FestivalAPI
        public async Task <HttpResponseMessage> ModifFestival_ArtisteAsync(Festival_Artiste festival_Artiste)
        {
            try
            {
                HttpResponseMessage response = await client.PutAsJsonAsync("api/festival_Artistes/" + festival_Artiste.Id, festival_Artiste);

                response.EnsureSuccessStatusCode();
                return(response);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            return(null);
        }