Exemplo n.º 1
0
        /// <summary>
        /// Determines whether specified instance of <see cref="SteamGameInfo" /> is equal to caller
        /// object.
        /// </summary>
        /// <param name="other">Other object to compare.</param>
        /// <returns><c>true</c> if values are memberwise equals, <c>false</c> otherwise.</returns>
        private bool IsEqual(SteamGameInfo other)
        {
            // Note: list with genre IDs usually has only few items and that is why comparison
            // using contains method is considered the best option here.

            return(Price.Equals(other.Price) &&
                   RequiredAge.Equals(other.RequiredAge) &&
                   GenreIds.All(genreId => other.GenreIds.Contains(genreId)) &&
                   string.Equals(PosterPath, other.PosterPath, StringComparison.Ordinal));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Determines whether specified instance of <see cref="OmdbMovieInfo" /> is equal to caller
        /// object.
        /// </summary>
        /// <param name="other">Other object to compare.</param>
        /// <returns><c>true</c> if values are memberwise equals, <c>false</c> otherwise.</returns>
        private bool IsEqual(OmdbMovieInfo other)
        {
            // Note: list with genre IDs usually has only few items and that is why comparison
            // using contains method is considered the best option here.

            return(string.Equals(Rated, other.Rated, StringComparison.Ordinal) &&
                   Metascore.Equals(other.Metascore) &&
                   GenreIds.All(genreId => other.GenreIds.Contains(genreId)) &&
                   string.Equals(PosterPath, other.PosterPath, StringComparison.Ordinal));
        }
Exemplo n.º 3
0
 public void RemoveActorId(int actorId)
 {
     if (!GenreIds.Contains(actorId))
     {
         throw new Exception("Actor with this ID was not found");
     }
     else
     {
         GenreIds.Remove(actorId);
     }
 }
Exemplo n.º 4
0
 public void RemoveGenreId(int genreId)
 {
     if (!GenreIds.Contains(genreId))
     {
         throw new Exception("Genre ID was not found");
     }
     else
     {
         GenreIds.Remove(genreId);
     }
 }
Exemplo n.º 5
0
        /// <summary>
        /// Determines whether specified instance of <see cref="TmdbMovieInfo" /> is equal to caller
        /// object.
        /// </summary>
        /// <param name="other">Other object to compare.</param>
        /// <returns><c>true</c> if values are memberwise equals, <c>false</c> otherwise.</returns>
        private bool IsEqual(TmdbMovieInfo other)
        {
            // Note: list with genre IDs usually has only few items and that is why comparison
            // using contains method is considered the best option here.

            const double eps = 1e-6;

            return(Math.Abs(Popularity - other.Popularity) < eps &&
                   Adult.Equals(other.Adult) &&
                   GenreIds.All(genreId => other.GenreIds.Contains(genreId)) &&
                   string.Equals(PosterPath, other.PosterPath, StringComparison.Ordinal));
        }
Exemplo n.º 6
0
        public IEnumerable <ValidationResult> Validate(ValidationContext validationContext)
        {
            if (ReleaseDate > DateTime.Now)
            {
                yield return(new ValidationResult("Date must me less than current date"));
            }

            if (!GenreIds.Any())
            {
                yield return(new ValidationResult("Game must have at least one genre"));
            }
        }
Exemplo n.º 7
0
 public void AddActorId(int actorId)
 {
     if (ActorsIds.Contains(actorId))
     {
         throw new Exception("This actor ID is already in the list");
     }
     if (actorId < 0)
     {
         throw new Exception("Actor's ID cannot be negative");
     }
     else
     {
         GenreIds.Add(actorId);
     }
 }
Exemplo n.º 8
0
 public void AddGenreId(int genreId)
 {
     if (GenreIds.Contains(genreId))
     {
         throw new Exception("This genre ID is already in the list");
     }
     if (genreId < 0)
     {
         throw new Exception("Genre ID cannot be negative");
     }
     else
     {
         GenreIds.Add(genreId);
     }
 }
Exemplo n.º 9
0
        public MangaDTO(Manga manga)
        {
            Id               = manga.Id;
            Name             = manga.Name;
            ReleaseDate      = manga.ReleaseDate;
            Volume           = manga.Volume;
            ReleaseContinues = manga.ReleaseContinues;
            Translater       = manga.Translater;
            Author           = manga.Author;
            PhotoBase64      = manga.PhotoBase64;

            foreach (Genre genre in manga.Genre)
            {
                GenreIds.Add(genre.Id);
            }
        }
Exemplo n.º 10
0
        public AnimeDTO(Anime anime)
        {
            Id            = anime.Id;
            Name          = anime.Name;
            ReleaseDate   = anime.ReleaseDate;
            Studio        = anime.Studio;
            Type          = anime.Type;
            CountEpisodes = anime.CountEpisodes;
            Status        = anime.Status;
            Source        = anime.Source;
            Season        = anime.Season;
            PhotoBase64   = anime.PhotoBase64;

            foreach (Genre genre in anime.Genres)
            {
                GenreIds.Add(genre.Id);
            }

            foreach (Studio voice in anime.Voices)
            {
                VoiceIds.Add(voice.Id);
            }
        }