Exemple #1
0
 /// <summary>
 /// Diese Methode aktualisiert die übergebene Zeile in der Datenbank
 /// </summary>
 /// <param name="elementToUpdate"></param>
 public void Update(Album elementToUpdate)
 {
     if (elementToUpdate == null)
     {
         throw new ArgumentException("elementToUpdate == null");
     }
     log.DebugFormat("updateAlbum: id={0}", elementToUpdate.Id);
     using (var context = new MP3ManagerContext())
     {
         context.Albums.Attach(elementToUpdate);
         context.SaveChanges();
     }                
 }
Exemple #2
0
 /// <summary>
 /// Diese Methode löscht die angegebene Row aus dem Dataset und aus der Datenbanktabelle
 /// </summary>
 /// <param name="album"></param>
 private void DeleteAlbum(Album album)
 {
     using (var context = new MP3ManagerContext())
     {
         context.Albums.Remove(album);
         context.SaveChanges();
     }
 }
Exemple #3
0
 /// <summary>
 /// This method inserts a new tile row
 /// </summary>
 /// <param name="mp3Info">
 /// The data to insert
 /// </param>
 /// <param name="interpretRow">
 /// The referenced interpret row
 /// </param>
 /// <param name="albumRow">
 /// The referenced album row
 /// </param>
 /// <returns>
 /// The inserted title row if the insertion was successfull, null else
 /// </returns>
 private Title InsertTitle(WMP3FileInfo mp3Info, Interpret interpretRow, Album albumRow)
 {
     if (mp3Info == null)
     {
         throw new ArgumentException("mp3Info == null");
     }
     if (interpretRow == null)
     {
         throw new ArgumentException("interpretRow == null");
     }
     if (albumRow == null)
     {
         throw new ArgumentException("albumRow == null");
     }
     if (String.IsNullOrWhiteSpace(mp3Info.Title))
     {
         throw new ArgumentException("Title null or empty");
     }
     log.DebugFormat("InsertTitle: tile={0}", mp3Info.Title);
     Title titleRow = null;
     long start = DateTime.Now.Ticks;
     using (var context = new MP3ManagerContext())
     {
         string normalizedName = CreateSearchname(mp3Info.Title);
         titleRow = context.Titles.Add(new Title()
          {
              Interpret = interpretRow,
              Album = albumRow,
              Name = mp3Info.Title,
              Length = mp3Info.Songlength,
              Bitrate = mp3Info.BitRate,
              Bytes = mp3Info.Bytes,
              Path = mp3Info.Path,
              Filename = mp3Info.Filename,
              Searchname = normalizedName,
              Track = mp3Info.Track,
              CreationDate = DateTime.Now,
              EditDate = mp3Info.EditDate,
              IsOrdered = false,
              IsCollection = false,
              DurationInSeconds = mp3Info.DurationInSeconds,
              Genre = mp3Info.Genre,
              PublicationYear = mp3Info.PublicationYear,
              SampleRate = mp3Info.SampleRate,
              Channels = mp3Info.Channels
          });
         context.SaveChanges();
         return titleRow;
     }
 }