public Album CreateAlbum(string name, string description, bool isPublic, IEnumerable <Tag> tags, int categoryId)
        {
            var oldAlbum = UnitOfWork.Albums.Get(album => album.Name.Equals(name));

            if (oldAlbum != null)
            {
                throw new DataException("Album name already exists.");
            }

            if (tags == null)
            {
                tags = new Tag[] { };
            }

            var newAlbum = new AlbumEntity
            {
                CategoryId  = categoryId,
                CreatedOn   = DateTime.UtcNow,
                Description = description,
                IsPublic    = isPublic,
                Name        = name,
                Tags        = tags.Select(tag => new TagEntity {
                    Id = tag.Id
                }).ToList(),
            };

            newAlbum = UnitOfWork.Albums.Add(newAlbum);

            UnitOfWork.Commit();

            return(newAlbum.ToModel());
        }
        public Album UpdateAlbumCover(int albumId, int albumCoverId)
        {
            var oldAlbum = UnitOfWork.Albums.GetById(albumId);

            if (oldAlbum == null)
            {
                throw new DataException("Album could not be retrieved.");
            }

            var newAlbum = new AlbumEntity
            {
                AlbumCoverId = albumCoverId
            };

            newAlbum = UnitOfWork.Albums.Update(newAlbum);
            UnitOfWork.Commit();

            return(newAlbum.ToModel());
        }