public static bool EditSaveFileinfoChanges(int id, MP3Record record) { try { var context = new MyJukeboxEntities(); var file = context.tFileInfoes.Find(id); if (file.FileSize != record.FileSize) { file.FileSize = record.FileSize; } if (file.FileDate != record.FileDate) { file.FileDate = record.FileDate; } if (file.Duration != record.Duration) { file.Duration = record.Duration; } context.SaveChanges(); return(true); } catch (Exception ex) { return(false); } }
public static bool EditSaveSongChanges(int id, MP3Record record) { try { var context = new MyJukeboxEntities(); var songs = context.tSongs.Find(id); if (songs.ID_Genre != GetGenreFromString(record.Genre)) { songs.ID_Genre = GetGenreFromString(record.Genre); } if (songs.ID_Catalog != GetCatalogFromString(record.Catalog)) { songs.ID_Catalog = GetCatalogFromString(record.Catalog); } if (songs.Album != record.Album) { songs.Album = record.Album; } if (songs.Artist != record.Artist) { songs.Artist = record.Artist; } if (songs.Titel != record.Titel) { songs.Titel = record.Titel; } if (songs.Pfad != record.Path) { songs.Pfad = record.Path; } if (songs.FileName != record.FileName) { songs.FileName = record.FileName; } context.SaveChanges(); return(true); } catch { return(false); } }
public static MP3Record GetRecordInfo(string startDirectory) { MP3Record record = null; // no special import string[] arTmp = startDirectory.Split('\\'); if (arTmp.Length < 5) { return(record); } List <int> media; string type = arTmp[arTmp.Length - 3]; var context = new MyJukeboxEntities(); media = context.tMedias .Where(m => m.Type == type) .Select(m => m.ID).ToList(); try { record = new MP3Record(); record.Album = arTmp[arTmp.Length - 1]; record.Artist = arTmp[arTmp.Length - 2]; record.Media = media[0]; record.Genre = arTmp[arTmp.Length - 5]; record.Catalog = arTmp[arTmp.Length - 4]; return(record); } catch (Exception ex) { //MessageBox.Show("Media Type not found!", ex.Message); return(null); } }