public OperationResultSet <string> GetAllGenres(string userName, string guid) { if (!CheckAuthenticated(userName, guid)) { return(new OperationResultSet <string>(Library.Models.OperationResult.ErrorEnum.NotAuthenticated, "Please authenticate first!")); } using (GenreData dataProvider = new GenreData()) { try { string[] result = dataProvider.GetAllGenres(); if (result == null) { return(new OperationResultSet <string>(new List <string>())); } return(new OperationResultSet <string>(new List <string>(result))); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine("BookManagement : GetAllGenres : " + ex.StackTrace); return(new OperationResultSet <string>(Library.Models.OperationResult.ErrorEnum.InternalProblem, "Some internal problem has occured")); } } }
static DataRepository() { Track = new TrackData(); Playlist = new PlaylistData(); Genre = new GenreData(); Artist = new ArtistData(); Album = new AlbumData(); }
/// <summary> /// Sets global tracks filters. /// </summary> /// <param name="albumArtistFilter">Optionnal; <see cref="AlbumData.AlbumArtist"/> filter.</param> /// <param name="albumFilter">Optionnal; <see cref="TrackData.Album"/> filter.</param> /// <param name="genreFilter">Optionnal; <see cref="TrackData.Genres"/> filter.</param> /// <param name="performerFilter">Optionnal; <see cref="TrackData.Performers"/> filter.</param> /// <param name="yearFilter">Optionnal; <see cref="TrackData.Year"/> filter.</param> public void SetGlobalTracksFilters(AlbumArtistData albumArtistFilter = null, AlbumData albumFilter = null, GenreData genreFilter = null, PerformerData performerFilter = null, uint?yearFilter = null) { _albumArtistGlobalFilter = albumArtistFilter; _albumGlobalFilter = albumFilter; _genreGlobalFilter = genreFilter; _performerGlobalFilter = performerFilter; _yearGlobalFilter = yearFilter; }
public void Delete(GenreData item) { var genre = new Genre() { Id = item.Id }; uow.Genres.Delete(genre); uow.SaveChanges(); }
public List <GenreData> ExtractGenres(string input) { var genreNames = input.Split(new char[] { ',' }); var genresDoneRight = genreNames.Select(l => new GenreData { Genre = GenreData.StringToGenre(l) }).ToList(); return(genresDoneRight); }
public void Add(GenreData item) { var genre = new Genre() { GenreName = item.GenreName, LastUpdate = DateTime.Now }; uow.Genres.Add(genre); uow.SaveChanges(); }
protected override void LazySet() { base.LazySet(); if (PersistenceState == PersistenceState.NewAndChanged || PersistenceState == PersistenceState.LoadedAndChanged) { if ((object)InnerData == (object)OriginalData) { OriginalData = new GenreData(InnerData); } } }
public IEnumerable <GenreData> GetAll() { var genres = uow.Genres.GetAll().ToList(); List <GenreData> nGenres = new List <GenreData>(); genres.ForEach(genre => { var g = new GenreData() { Id = genre.Id, GenreName = genre.GenreName }; nGenres.Add(g); }); return(nGenres); }
/// <summary> /// Constructor. /// </summary> /// <param name="sourceData"><see cref="BaseItemData.SourceData"/></param> /// <param name="library"><see cref="LibraryEngine"/></param> /// <exception cref="ArgumentNullException"><paramref name="library"/> is <c>Null</c>.</exception> /// <exception cref="ArgumentNullException"><paramref name="sourceData"/> is <c>Null</c>.</exception> public GenreItemData(GenreData sourceData, LibraryEngine library) : base(sourceData) { if (library == null) { throw new ArgumentNullException(nameof(library)); } if (sourceData == null) { throw new ArgumentNullException(nameof(sourceData)); } IEnumerable <TrackData> tracks = library.Tracks.Where(t => t.Genres.Contains(sourceData)); TracksCount = tracks.Count(); TracksLength = new TimeSpan(0, 0, (int)tracks.Sum(t => t.Length.TotalSeconds)); }
public bool Validate() { bool validGenre; using (GenreData genreData = new GenreData()) { validGenre = genreData.GetGenreIdByName(Genre) >= 0; } bool validType; using (TypeData typeData = new TypeData()) { validType = typeData.GetTypeIdByName(Type) >= 0; } bool validAuthorId; using (AuthorData authorData = new AuthorData()) { validAuthorId = authorData.GetAuthorById(Author.AuthorId) != null; } bool validUserName; using (UserData userData = new UserData()) { validUserName = userData.GetUserByUserName(User.UserName) != null; } if (!validGenre || !validType || !validAuthorId || !validUserName || String.IsNullOrEmpty(Title) || Year < 0 || String.IsNullOrEmpty(Isbn)) { return(false); } return(true); }
public bool ValidateEdit() { bool validBookId; using (BookData genreData = new BookData()) { validBookId = genreData.GetBookById(BookId) != null; } bool validGenre; using (GenreData genreData = new GenreData()) { validGenre = genreData.GetGenreIdByName(Genre) >= 0; } bool validType; using (TypeData typeData = new TypeData()) { validType = typeData.GetTypeIdByName(Type) >= 0; } bool validAuthorId; using (AuthorData authorData = new AuthorData()) { validAuthorId = authorData.GetAuthorById(Author.AuthorId) != null; } if (!validGenre || !validType || !validAuthorId || !validBookId || String.IsNullOrEmpty(Title) || Year < 0 || String.IsNullOrEmpty(Isbn)) { return(false); } return(true); }
public void Delete(GenreData item) { Channel.Delete(item); }
public void Add(GenreData item) { Channel.Add(item); }
public GenreData(GenreData data) { Uid = data.Uid; Name = data.Name; Movies = data.Movies; }
private void TreatSingleFile(int i, string file, Dictionary <KeyValuePair <string, bool>, AlbumArtistData> localAlbumArtistDatas, Dictionary <KeyValuePair <KeyValuePair <string, AlbumArtistData>, bool>, AlbumData> localAlbumDatas, Dictionary <KeyValuePair <string, bool>, GenreData> localGenreDatas, Dictionary <KeyValuePair <string, bool>, PerformerData> localPerformerDatas) { try { TagFile tagFile = TagFile.Create(file); TrackData track; if (tagFile != null) { if (tagFile.Tag != null) { TagLib.Tag tag = tagFile.Tag; AlbumArtistData albumArtist = localAlbumArtistDatas[new KeyValuePair <string, bool>(_NULL, true)]; AlbumData album = localAlbumDatas[new KeyValuePair <KeyValuePair <string, AlbumArtistData>, bool>(new KeyValuePair <string, AlbumArtistData>(_NULL, albumArtist), true)]; var performers = new List <PerformerData>(); var genres = new List <GenreData>(); var sourceAlbumArtists = new List <string>(); if (tag.AlbumArtists?.Length > 1) { LoadingLogHandler?.BeginInvoke(this, new LoadingLogEventArgs(new LogData($"Multiple album artists for the file : {file}.", LogLevel.Warning), i), null, null); } if (tag.AlbumArtists != null) { sourceAlbumArtists = tag.AlbumArtists.Where(aa => aa != null).ToList(); } if (tag.FirstAlbumArtist != null) { if (!localAlbumArtistDatas.TryGetValue(new KeyValuePair <string, bool>(tag.FirstAlbumArtist, false), out albumArtist)) { albumArtist = new AlbumArtistData(tag.FirstAlbumArtist, false); localAlbumArtistDatas.Add(new KeyValuePair <string, bool>(tag.FirstAlbumArtist, false), albumArtist); } } if (tag.Album != null) { var key = new KeyValuePair <string, AlbumArtistData>(tag.Album, albumArtist); if (!localAlbumDatas.TryGetValue(new KeyValuePair <KeyValuePair <string, AlbumArtistData>, bool>(key, false), out album)) { album = new AlbumData(albumArtist, tag.Album, false); localAlbumDatas.Add(new KeyValuePair <KeyValuePair <string, AlbumArtistData>, bool>(key, false), album); } } if (tag.Performers != null) { foreach (string performer in tag.Performers) { PerformerData performerd = localPerformerDatas[new KeyValuePair <string, bool>(_NULL, true)]; if (performer != null) { if (!localPerformerDatas.TryGetValue(new KeyValuePair <string, bool>(performer, false), out performerd)) { performerd = new PerformerData(performer, false); localPerformerDatas.Add(new KeyValuePair <string, bool>(performer, false), performerd); } } if (!performers.Contains(performerd)) { performers.Add(performerd); } } } if (tag.Genres != null) { foreach (string genre in tag.Genres) { GenreData genred = localGenreDatas[new KeyValuePair <string, bool>(_NULL, true)]; if (genre != null) { if (!localGenreDatas.TryGetValue(new KeyValuePair <string, bool>(genre, false), out genred)) { genred = new GenreData(genre, false); localGenreDatas.Add(new KeyValuePair <string, bool>(genre, false), genred); } } if (!genres.Contains(genred)) { genres.Add(genred); } } } List <byte> frontCoverDatas = ExtractFrontCoverInformations(tag, out string frontCoverMimeType); track = new TrackData(tag.Track, tag.Title ?? _NULL, album, performers, genres, tag.Year, (tagFile.Properties?.Duration).GetValueOrDefault(TimeSpan.Zero), tagFile.Name, sourceAlbumArtists, GetMimeType(tagFile.MimeType), frontCoverMimeType, frontCoverDatas); } else { track = new TrackData(tagFile.Name, (tagFile.Properties?.Duration).GetValueOrDefault(TimeSpan.Zero), localAlbumDatas[new KeyValuePair <KeyValuePair <string, AlbumArtistData>, bool>(new KeyValuePair <string, AlbumArtistData>(_NULL, localAlbumArtistDatas[new KeyValuePair <string, bool>(_NULL, true)]), false)], GetMimeType(tagFile.MimeType)); } } else { track = new TrackData(file, TimeSpan.Zero, localAlbumDatas[new KeyValuePair <KeyValuePair <string, AlbumArtistData>, bool>(new KeyValuePair <string, AlbumArtistData>(_NULL, localAlbumArtistDatas[new KeyValuePair <string, bool>(_NULL, true)]), false)], tagFile.MimeType); } _tracks.Add(track); LoadingLogHandler?.BeginInvoke(this, new LoadingLogEventArgs(new LogData($"The file {file} has been processed.", LogLevel.Information), i), null, null); } catch (Exception exLocal) { LoadingLogHandler?.BeginInvoke(this, new LoadingLogEventArgs(new LogData($"Error while processing {file}.", LogLevel.Error, new KeyValuePair <string, string>("Error message", exLocal.Message)), i), null, null); } }