public static bool AddMediafile(Mediafile file, int index = -1) { if (file != null) { if (service == null) { service = new LibraryService(new DatabaseService()); } SettingsViewModel.TracksCollection.Elements.Insert(index == -1 ? SettingsViewModel.TracksCollection.Elements.Count: index, file); service.AddMediafile(file); return(true); } return(false); }