public async Task <IHttpActionResult> PostArtiste(Artiste artiste) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.Artistes.Add(artiste); await db.SaveChangesAsync(); //db.Entry(artiste).Reference(x => x.Programmations).Load(); var dto = new ArtisteDTO() { ArtisteID = artiste.ArtisteID, Comment = artiste.Comment, ArtisteNom = artiste.ArtisteNom, //ProgrammationId = artiste.Programmation.ProgrammationId, MusicExtract = artiste.MusicExtract, Nationality = artiste.Nationality, Photo = artiste.Photo, Style = artiste.Style }; return(CreatedAtRoute("DefaultApi", new { id = artiste.ArtisteID }, dto)); }
public async Task <IHttpActionResult> PutArtiste(int id, Artiste artiste) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != artiste.ArtisteID) { return(BadRequest()); } db.Entry(artiste).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ArtisteExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IActionResult ManagePOST(ManageArtistesViewModel manageArtistesViewModel) { if (ModelState.IsValid) { Artiste artiste = new Artiste { IdArtiste = (manageArtistesViewModel.Artiste.IdArtiste != 0) ? manageArtistesViewModel.Artiste.IdArtiste : 0, Biographie = manageArtistesViewModel.Artiste.Biographie, Nom = manageArtistesViewModel.Artiste.NomArtiste, IdPays = manageArtistesViewModel.Artiste.IdPays, Pays = _paysRepository.Find(manageArtistesViewModel.Artiste.IdPays), DateNaissance = manageArtistesViewModel.Artiste.DateNaissance }; if (manageArtistesViewModel.Artiste.IdArtiste != 0) { _artisteRepository.Update(artiste); } else { _artisteRepository.Add(artiste); } return(RedirectToAction(nameof(ArtistesController.Index), "Artistes", new { area = "Administration" })); } else { InitializePaysList(manageArtistesViewModel); return(this.View(nameof(ArtistesController.Manage), manageArtistesViewModel)); } }
public IActionResult Consult(int id) { if (HttpContext.Session.GetInt32("idf") == null) { return(null); } else { int FestivalierId = (int)HttpContext.Session.GetInt32("idf"); Ami ami = (Ami)API.Instance.GetAmitiéAsync(FestivalierId, id).Result; if (ami != null) { IEnumerable <Favoris> favoris = API.Instance.GetFavorisAsync().Result.Where(s => s.FestivalierId == id && s.Like == true); List <Artiste> artistes = new List <Artiste>(); foreach (var item in favoris) { Artiste artiste = new Artiste(); artiste = (Artiste)API.Instance.GetArtisteAsync(item.ArtisteId).Result; artistes.Add(artiste); } ViewBag.Artistes = artistes; } return(View()); } }
public ArtisteAdminViewModel() { Artiste = new Artiste(); Artiste.Nom = ""; Artiste.Biographie = ""; MessageErreur = null; }
public async Task <IActionResult> PutArtiste(int id, Artiste artiste) { if (id != artiste.IdA) { return(BadRequest()); } _context.Entry(artiste).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ArtisteExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public int CreerArtiste(string sonNom, string sonSite, int sonCourant, out string msgErreur) { msgErreur = ""; int ajoutArtiste = 0; Courant unCourant; Artiste unArtiste; if (sonNom == "") { msgErreur += "\nVeuillez saisir le nom de l'artiste"; } if (sonCourant == 0) { msgErreur += "\nVeuillez saisir le courant de l'artiste"; } if (msgErreur == "") { unCourant = new Courant(sonCourant); unArtiste = new Artiste(sonNom, sonSite, unCourant); try { ajoutArtiste = ArtisteDAO.GetInstance().AjoutArtiste(unArtiste); } catch (Exception err) { msgErreur = "Erreur lors de la création du client" + err.Message; } } return(ajoutArtiste); }
public List <Artiste> List_Artiste() { List <Artiste> list_Artiste = new List <Artiste>(); using (SqlConnection connection = new SqlConnection(connectionString)) { string sqlQuery = "Select * from dbo.Artiste"; SqlCommand command = new SqlCommand(sqlQuery, connection); connection.Open(); SqlDataReader reader = command.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { Artiste artiste = new Artiste(); artiste.IdA = reader.GetInt32(0); artiste.Nom = reader.GetString(1); artiste.PaysId = reader.GetInt32(2); artiste.Photo = reader.GetString(3); artiste.Prenom = reader.GetString(4); artiste.StyleId = reader.GetInt32(5); list_Artiste.Add(artiste); } } return(list_Artiste); } }
/// <summary> /// Met à jour un titre /// </summary> /// <param name="titre">Titre mis à jour</param> void ITitreRepository.Update(Titre titre) { Titre titreContext = _dbContext.Titres.Where(t => t.IdTitre == titre.IdTitre).Include(t => t.Artiste).Include(t => t.Commentaires).Include(t => t.LienStyle).ThenInclude(l => l.Style).FirstOrDefault(); Artiste artisteContext = _dbContext.Artistes.FirstOrDefault(x => x.IdArtiste == titre.IdArtiste); titreContext.IdTitre = titre.IdTitre; titreContext.Libelle = titre.Libelle; titreContext.IdArtiste = artisteContext.IdArtiste; titreContext.Artiste = artisteContext; titreContext.Chronique = titre.Chronique; titreContext.DateSortie = titre.DateSortie; titreContext.Duree = titre.Duree; titreContext.UrlEcoute = titre.UrlEcoute; titreContext.UrlJaquette = titre.UrlJaquette; titreContext.LienStyle.ToList().ForEach(s => { if (!titre.LienStyle.Any(x => x.IdStyle == s.IdStyle)) { titreContext.LienStyle.Remove(s); } }); foreach (var newStyle in titre.LienStyle) { if (!titreContext.LienStyle.Any(x => x.IdStyle == newStyle.IdStyle)) { Style style = _dbContext.Styles.FirstOrDefault(styleContext => styleContext.IdStyle == newStyle.IdStyle); titreContext.LienStyle.Add(new LienStyle { IdStyle = style.IdStyle, Style = style, IdTitre = titre.IdTitre, Titre = titreContext });; } } _dbContext.SaveChanges(); }
public int AjoutArtiste(Artiste unArtiste) { string nomArtiste; string site; int nbAjout = 0; int idCourant = 0; // on récupère l'objet responsable de la connexion à la base SqlConnection cnx = Connexion.GetObjConnexion(); maCommand = new SqlCommand(); maCommand.Connection = cnx; // requête SQL execution maCommand.CommandText = "ajoutartiste"; maCommand.CommandType = System.Data.CommandType.StoredProcedure; nomArtiste = unArtiste.Nom; site = unArtiste.Site; idCourant = unArtiste.LeCourant.Id; maCommand.Parameters.Add("nom", System.Data.SqlDbType.VarChar); maCommand.Parameters.Add("site", System.Data.SqlDbType.VarChar); maCommand.Parameters.Add("idCourant", System.Data.SqlDbType.Int); maCommand.Parameters[0].Value = nomArtiste; maCommand.Parameters[1].Value = site; maCommand.Parameters[2].Value = idCourant; nbAjout = maCommand.ExecuteNonQuery(); return(nbAjout); }
/// <summary> /// TO DO. /// </summary> /// <param name="name">TO DO.</param> /// <returns>TO DO.</returns> public IActionResult Index(string name) { try { Artiste artist = this.artisteRepository.Find(name); artist.Titres.OrderBy(t => t.Album); // Get all albums names by distinct names var albums = new Dictionary <string, string>(); foreach (var titre in artist.Titres) { if (!albums.ContainsKey(titre.Album)) { albums.Add(titre.Album, titre.UrlJaquette); // Set album name as key and url image as value } } ArtistViewModel model = new ArtistViewModel() // model for the view { Artist = artist, Albums = albums }; return(this.View(model)); } catch (Exception e) { return(this.NotFound()); } }
public List <Artiste> Return_Artiste_By_Style(int StyleId) { List <Artiste> artistes = new List <Artiste>(); using (SqlConnection connection = new SqlConnection(connectionString)) { string sqlQuery = "Select * from dbo.Artiste where StyleId = " + StyleId; SqlCommand command = new SqlCommand(sqlQuery, connection); connection.Open(); SqlDataReader reader = command.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { Artiste artiste = new Artiste(); artiste.IdA = reader.GetInt32(0); artiste.Nom = reader.GetString(1); artiste.Prenom = reader.GetString(2); artiste.Photo = reader.GetString(3); artiste.StyleId = reader.GetInt32(4); artiste.Descriptif = reader.GetString(5); artiste.PaysId = reader.GetInt32(6); artiste.Extrait = reader.GetString(7); artistes.Add(artiste); } } } return(artistes); }
public async Task <ActionResult <Artiste> > PostArtiste(Artiste artiste) { _context.Artiste.Add(artiste); await _context.SaveChangesAsync(); return(CreatedAtAction("GetArtiste", new { id = artiste.IdA }, artiste)); }
/// <summary> /// Supprime un artiste du set de données /// </summary> /// <param name="artiste">Artiste à supprimer</param> void IArtisteRepository.Delete(Artiste artiste) { // Si l'artiste existe dans le set, suppression if (StaticFactory.Artistes.Contains(artiste)) { StaticFactory.Artistes.Remove(artiste); } }
public NewArtistePage() { InitializeComponent(); Item = new Artiste("test"); BindingContext = this; }
public ActionResult DeleteConfirmed(int id) { Artiste artiste = db.Artistes.Find(id); db.Entry(artiste).State = EntityState.Deleted; db.SaveChanges(); return(RedirectToAction("Index")); }
/// <summary> /// Met à jour l'artiste correspondant à l'artiste entré en paramètre. /// </summary> /// <param name="artiste"></param> public void Update(Artiste artiste) { var artisteUpdate = _context.Artistes.Find(artiste.IdArtiste); artisteUpdate.Nom = artiste.Nom; artisteUpdate.Biographie = artiste.Biographie; _context.Artistes.Update(artisteUpdate); _context.SaveChanges(); }
/// <summary> /// Ajoute un artiste dans le set de données /// </summary> /// <param name="artiste">Artiste à ajouter</param> void IArtisteRepository.Add(Artiste artiste) { Pays paysContext = _dbContext.Pays.FirstOrDefault(x => x.IdPays == artiste.IdPays); artiste.IdPays = paysContext.IdPays; artiste.Pays = paysContext; _dbContext.Artistes.Add(artiste); _dbContext.SaveChanges(); }
//public void ExecutedC() //uploader image //{ // if(_fileOpen.OpenFile()) // { // var selectedFile = this._fileOpen.FileName; // } //} #endregion public ArtisteFormulaireViewModel(IRegionManager regionManager, IEventAggregator eventAggregator) { _eventAggregator = eventAggregator; _regionManager = regionManager; Artiste = new Artiste(); CreerArtiste = new DelegateCommand <string>(ExecutedA); GoToGestionArtiste = new DelegateCommand <string>(ExecutedB); //UploadImage = new DelegateCommand(ExecutedC); NotificationRequest = new InteractionRequest <INotification>(); }
// GET: Artiste/Delete/5 public ActionResult Delete(int id) { Artiste artiste = _artisteRepository.GetById(id); if (artiste != null) { return(View(artiste)); } return(View()); }
public void Delete(int ArtisteId) { Artiste artiste = this._context.Artists.Find(ArtisteId); if (artiste != null) { this._context.Artists.Remove(artiste); this._context.SaveChanges(); } }
/// <summary> /// Ajoute un artiste dans le set de données /// </summary> /// <param name="artiste">Artiste à ajouter</param> void IArtisteRepository.Add(Artiste artiste) { artiste.IdArtiste = StaticFactory.Artistes.Max(x => x.IdArtiste) + 1; // Application de la binavigabilité artiste.Titres = StaticFactory.Titres.Where(t => t.Artiste.Nom == artiste.Nom).ToList(); // Ajout de l'Artiste dans le set de données StaticFactory.Artistes.Add(artiste); }
/// <summary> /// call l'interface qui modifira l'artiste /// </summary> /// <param name="artiste">artiste a modifier avec ses nouveau paramètre</param> private void UpdateArtiste(Artiste artiste) { try { Startup.iartisteRepository.Update(artiste); } catch (Exception) { throw; } }
public ActionResult Edit([Bind(Include = "Id,Nom,Prenom")] Artiste artiste) { if (ModelState.IsValid) { db.Entry(artiste).State = EntityState.Modified; db.SaveChanges(); var state = db.Entry(artiste).State; return(RedirectToAction("Index")); } return(View(artiste)); }
// GET: Artiste/Edit/5 public ActionResult Edit(int id) { Artiste artiste = this._artisteRepository.GetById(id); ArticteEditModel artisteModel = new ArticteEditModel(); artisteModel.Id = artiste.Id; artisteModel.Name = artiste.Name; artisteModel.ExistingPhotoPath = artiste.Image; return(View(artisteModel)); }
public AddArtist() { bm = new BusinessManager(); InitializeComponent(); _currentArtiste = new Artiste(); foreach (string str in bm.getArtistesSortByName()) { this.ListArtist.Items.Add(str.ToString()); } }
public async Task <IHttpActionResult> GetArtiste(int id) { Artiste artiste = await db.Artistes.FindAsync(id); if (artiste == null) { return(NotFound()); } return(Ok(artiste)); }
public ModifierArtisteViewModel(IEventAggregator eventAggregator, IRegionManager regionManager) { _eventAggregator = eventAggregator; _regionManager = regionManager; NotificationRequest = new InteractionRequest <INotification>(); _eventAggregator.GetEvent <PassArtisteEvent>().Subscribe(Update); ModifierArtiste = new DelegateCommand <string>(ExecutedA); GoToGestionArtiste = new DelegateCommand <string>(ExecutedB); Artiste = new Artiste(); InitialStyles(); InitialNationalities(); }
public ActionResult Edit(Artiste artiste) { try { _artisteRepository.Update(artiste); return(RedirectToAction(nameof(Index))); } catch { return(View()); } }
/// <summary> /// Met à jour un artiste dans le set de données /// </summary> /// <param name="artiste">Artiste modifié</param> void IArtisteRepository.Update(Artiste artiste) { // Si l'artiste existe bien if (!StaticFactory.Artistes.FirstOrDefault(a => a.IdArtiste == artiste.IdArtiste).Equals(default(Artiste))) { StaticFactory.Artistes.FirstOrDefault(a => a.IdArtiste == artiste.IdArtiste).Biographie = artiste.Biographie; StaticFactory.Artistes.FirstOrDefault(a => a.IdArtiste == artiste.IdArtiste).Nom = artiste.Nom; StaticFactory.Artistes.FirstOrDefault(a => a.IdArtiste == artiste.IdArtiste).Titres = artiste.Titres; StaticFactory.UpdateBinavigabilite(); } }
/// <summary> /// Met à jour un artiste dans le set de données /// </summary> /// <param name="artiste">Artiste modifié</param> void IArtisteRepository.Update(Artiste artiste) { Artiste artisteContext = _dbContext.Artistes.Where(t => t.IdArtiste == artiste.IdArtiste).Include(t => t.Pays).FirstOrDefault(); Pays paysContext = _dbContext.Pays.FirstOrDefault(x => x.IdPays == artiste.IdPays); artisteContext.Nom = artiste.Nom; artisteContext.Biographie = artiste.Biographie; artisteContext.IdPays = paysContext.IdPays; artisteContext.Pays = paysContext; artisteContext.DateNaissance = artiste.DateNaissance; _dbContext.SaveChanges(); }
/// <summary> /// Bouton ajouter /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Button_Click_1(object sender, RoutedEventArgs e) { if (this.TabArtiste.SelectedIndex == 0) { _currentArtiste.Nom = this.Nom.Text; _currentArtiste.Prenom = this.Prenom.Text; _currentArtiste.DateDeNaissance = this.Date.SelectedDate.Value; } else if (this.TabArtiste.SelectedIndex == -1) { _currentArtiste = null; } this.Close(); }
/// <summary> /// Selection changed dans la liste des Artistes /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ListArtist_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (this.ListArtist.SelectedIndex != -1) { _currentArtiste = bm.getArtistesTypeSortByName().ElementAt(this.ListArtist.SelectedIndex); } }
/// <summary> /// Bouton annuler /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Button_Click(object sender, RoutedEventArgs e) { _currentArtiste = null; this.Close(); }