Exemplo n.º 1
0
        public async Task <ArtistResponse> AddArtistAsync(AddArtistRequest request)
        {
            var item = new Entities.Artist {
                ArtistName = request.ArtistName
            };
            var result = _artistRepository.Add(item);

            await _artistRepository.UnitOfWork.SaveChangesAsync();

            return(_artistMapper.Map(result));
        }
        public async Task <ArtistResponse> Handle(AddArtistCommand command, CancellationToken cancellationToken)
        {
            var item = new Entities.Artist {
                ArtistName = command.ArtistName
            };

            var result = _artistRepository.Add(item);
            await _artistRepository.UnitOfWork.SaveChangesAsync(cancellationToken);

            return(new ArtistResponse {
                ArtistId = result.ArtistId, ArtistName = result.ArtistName
            });
        }
Exemplo n.º 3
0
        internal static Artist ToDto(Entities.Artist artist, bool include_relations, bool include_invisible_media)
        {
            if (artist == null)
            {
                return(null);
            }
            if (include_relations)
            {
                return(new Artist
                {
                    Id = artist.Id,
                    Name = artist.Name,
                    YearStarted = artist.YearStarted,
                    YearQuit = artist.YearQuit,

                    Text = artist.Text,
                    DateUpdate = artist.DateUpdate ?? artist.DateInsert,

                    PastMembers = artist.Members
                                  .Where(ap => !ap.Active)
                                  .Select(ap => PersonRepository.ToDto(ap.Person, false, include_invisible_media))
                                  .ToList(),
                    CurrentMembers = artist.Members
                                     .Where(ap => ap.Active)
                                     .Select(ap => PersonRepository.ToDto(ap.Person, false, include_invisible_media))
                                     .ToList(),
                    Songs = artist.Songs
                            .Select(@as => SongRepository.ToDto(@as.Song, false, include_invisible_media))
                            .ToList(),
                    Media = artist.Media == null ? null : artist.Media
                            .Where(medium => medium.Type.Visible | include_invisible_media)
                            .Select(medium => MediumRepository.ToDto(medium, true))
                            .ToList(),
                    Tags = artist.Tags == null ? null : artist.Tags.Select(st => TagRepository.ToDto(st.Tag)).ToList()
                });
            }
            else
            {
                return(new Artist
                {
                    Id = artist.Id,
                    Name = artist.Name,
                    YearStarted = artist.YearStarted,
                    YearQuit = artist.YearQuit,

                    Text = artist.Text,
                    DateUpdate = artist.DateUpdate ?? artist.DateInsert
                });
            }
        }
Exemplo n.º 4
0
        internal static Entities.Artist ToEntity(Artist artist, MintPlayerContext mintplayer_context)
        {
            if (artist == null)
            {
                return(null);
            }
            var entity_artist = new Entities.Artist
            {
                Id          = artist.Id,
                Name        = artist.Name,
                YearStarted = artist.YearStarted,
                YearQuit    = artist.YearQuit
            };

            #region Members
            var artist_person = artist.CurrentMembers.Select(person => {
                var entity_person = mintplayer_context.People.Find(person.Id);
                return(new Entities.ArtistPerson(entity_artist, entity_person)
                {
                    Active = true
                });
            }).Union(artist.PastMembers.Select(person => {
                var entity_person = mintplayer_context.People.Find(person.Id);
                return(new Entities.ArtistPerson(entity_artist, entity_person)
                {
                    Active = false
                });
            }));
            entity_artist.Members = artist_person.ToList();
            #endregion
            #region Media
            entity_artist.Media = artist.Media.Select(m => {
                var medium     = MediumRepository.ToEntity(m, mintplayer_context);
                medium.Subject = entity_artist;
                return(medium);
            }).ToList();
            #endregion
            #region Tags
            if (artist.Tags != null)
            {
                entity_artist.Tags = artist.Tags.Select(t =>
                {
                    var tag = mintplayer_context.Tags.Find(t.Id);
                    return(new Entities.SubjectTag(entity_artist, tag));
                }).ToList();
            }
            #endregion

            return(entity_artist);
        }
Exemplo n.º 5
0
        public static CrossCutting.TransferObjects.Artist ToTransferObject(this Entities.Artist Entity)
        {
            if (Entity is null)
            {
                throw new ArgumentNullException(nameof(Entity));
            }

            return(new CrossCutting.TransferObjects.Artist
            {
                Id = Entity.ArtistId,
                Name = Entity.Name,
                Description = Entity.Description,
                Country = Entity.Country,
                Type = Entity.Type,

                Albums = Entity.Albums?.Select(a => a.ToTransferObject()).ToList()
            });
        }
 public PlainArtistResponse(Entities.Artist artist)
 {
     Id   = artist.Id;
     Name = artist.Name;
 }