Skip to content

Commit

Permalink
Revert "feat(#65): added shared for community flag for songs and pl…
Browse files Browse the repository at this point in the history
…aylists"

This reverts commit 795875a.
  • Loading branch information
sashafromlibertalia committed Jun 21, 2022
1 parent 795875a commit 2742613
Show file tree
Hide file tree
Showing 15 changed files with 61 additions and 157 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ public class DomainToResponse : Profile
public DomainToResponse()
{
CreateMap<Domain.ListeningQueue, ListeningQueueInfoDto>();

CreateMap<Domain.Song, SongInfoDto>()
.ForMember(dest => dest.AuthorName, opt =>
.ForMember(dest => dest.AuthorName, opt=>
opt.MapFrom(src => src.Author.Name))
.ForMember(dest => dest.GenreName, opt =>
opt.MapFrom(src => src.Genre.Name));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ public async Task<Unit> Handle(CreateNewSongCommand request, CancellationToken c
var song = new Domain.Song
(
dto.Name,
genre,
user,
genre, user,
_storage.GenerateUri(),
Helpers.Helpers.ShouldGenerateUri(dto.Cover) ? _storage.GenerateUri() : null
);
Expand Down

This file was deleted.

This file was deleted.

1 change: 0 additions & 1 deletion Source/Application/DS.Application.DTOs/Song/SongInfoDto.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,5 @@ public record SongInfoDto
string GenreName,
string AuthorName,
string ContentUri,
bool SharedForCommunity,
string? CoverUri
);
10 changes: 3 additions & 7 deletions Source/Domain/DS.Domain/Song.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,13 @@ namespace DS.Domain;

public class Song : IEquatable<Song>
{
private readonly List<MusicUser> _featuring = new ();
private List<MusicUser> _featuring = new ();

#pragma warning disable CS0169
private readonly List<MediaLibrary> _addedToLibraries;
#pragma warning restore CS0169

protected Song()
{

}

protected Song() {}

public Song
(
Expand All @@ -29,7 +26,6 @@ public Song
Genre = genre.ThrowIfNull();
Author = author.ThrowIfNull();
ContentUri = songContentUri.ThrowIfNull();
SharedForCommunity = false;
CoverUri = coverUri;
Id = Guid.NewGuid();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace DS.DataAccess.Seeding.Generators;

public static class SongGenerator
public class SongGenerator
{
private const int MinFeaturing = 0;
private const int MaxFeaturing = 2;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,4 @@ public async Task<IActionResult> DeleteSongFromPlaylist([FromBody] DeleteSongFro
Task<GetPlaylistInfo.Response>? playlistInfo = _mediator.Send(new GetPlaylistInfo.GetInfoQuery(command.UserId, command.PlaylistId));
return Ok(playlistInfo);
}

[HttpPut(nameof(ChangePlaylistVisibility))]
public async Task<IActionResult> ChangePlaylistVisibility([FromBody] ChangePlaylistVisibility.ChangePlaylistVisibilityCommand command)
{
await _mediator.Send(command);
Task<GetPlaylistInfo.Response>? playlistInfo = _mediator.Send(new GetPlaylistInfo.GetInfoQuery(command.UserId, command.PlaylistId));
return Ok(playlistInfo);
}
}
9 changes: 0 additions & 9 deletions Source/Server/DS.Music.WebApi/Controllers/SongController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,11 @@ public async Task<IActionResult> AddFeaturingUser([FromBody] AddFeaturing.AddFea
return Ok(songInfo);
}


[HttpPut(nameof(RemoveFeaturingUser))]
public async Task<IActionResult> RemoveFeaturingUser([FromBody] RemoveFeaturing.RemoveFeaturingCommand command)
{
await _mediator.Send(command);
Task<GetSongInfo.Response>? songInfo = _mediator.Send(new GetSongInfo.GetInfoQuery(command.UserId, command.SongId));
return Ok(songInfo);
}

[HttpPut(nameof(ChangeSongVisibility))]
public async Task<IActionResult> ChangeSongVisibility([FromBody] ChangeSongVisibility.ChangeSongVisibilityCommand command)
{
await _mediator.Send(command);
Task<GetSongInfo.Response>? songInfo = _mediator.Send(new GetSongInfo.GetInfoQuery(command.UserId, command.SongId));
return Ok(songInfo);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,7 @@ public void InsertSongAfterExisting_SongInserted()
public void InsertNewSongOnIndexOutOfRange_ThrowsException(int index)
{
var playlistSongs = new PlaylistSongs(_songsToTest.SkipLast(1).ToList());
var newSong = new Song("_", new SongGenre("TestGenre"),
new MusicUser(Guid.NewGuid(), "f"),
"_");
var newSong = new Song("_", new SongGenre("TestGenre"), new MusicUser(Guid.NewGuid(), "f"), "_");

Assert.Throws<DoSvyaziMusicException>(() =>
{
Expand Down Expand Up @@ -143,10 +141,7 @@ public void GetAndSetSongAtIndex_AllDone(int index)
Assert.AreEqual(_songsToTest[index], element);
Assert.AreEqual(index, playlistSongs.IndexOf(element));

var newSong = new Song("aaa",
new SongGenre("TestGenre"),
new MusicUser(Guid.NewGuid(), "_"),
"_");
var newSong = new Song("aaa", new SongGenre("TestGenre"), new MusicUser(Guid.NewGuid(), "_"), "_");
playlistSongs[index] = newSong;
Assert.AreEqual(newSong, playlistSongs[index]);
Assert.AreEqual(index, playlistSongs.IndexOf(newSong));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
Expand Down Expand Up @@ -31,7 +30,7 @@ public void SetUp()
.Options;
_context = new MusicDbContext(options);

_musicUser = MusicUserGenerator.GenerateMusicUsers(Helpers.Helpers.Constants.SingleEntity).First();
_musicUser = MusicUserGenerator.GenerateMusicUsers(Helpers.Constants.SingleEntity).First();
_context.Add(_musicUser);

var songs = GenerateSongs(2);
Expand Down Expand Up @@ -77,7 +76,7 @@ public async Task ChangeQueueSongPosition_PositionChanged()
(
_musicUser.Id,
_firstSong.Id,
Helpers.Helpers.Constants.SingleEntity
Helpers.Constants.SingleEntity
);
await handler.Handle(changeSongsPositionCommand, CancellationToken.None);

Expand All @@ -96,8 +95,8 @@ public async Task ClearQueue_QueueCleared()
await handler.Handle(clearQueueCommand, CancellationToken.None);

Assert.IsEmpty(await GetQueueSongs());
Assert.True(Helpers.Helpers.EntityExistsInDatabase(_firstSong, _context));
Assert.True(Helpers.Helpers.EntityExistsInDatabase(_secondSong, _context));
Assert.True(Helpers.EntityExistsInDatabase(_firstSong, _context));
Assert.True(Helpers.EntityExistsInDatabase(_secondSong, _context));
}

[Test]
Expand All @@ -110,7 +109,7 @@ public async Task DeleteSongFromQueue_SongDeleted()
var command = new DeleteFromQueue.DeleteFromQueueCommand(_musicUser.Id, _firstSong.Id);
await handler.Handle(command, CancellationToken.None);

Assert.True(Helpers.Helpers.EntityExistsInDatabase(_firstSong, _context));
Assert.True(Helpers.EntityExistsInDatabase(_firstSong, _context));
Assert.False((await GetQueueSongs()).Contains(_firstSong));
Assert.Contains(_secondSong, await GetQueueSongs());
}
Expand All @@ -129,15 +128,15 @@ public async Task DeleteSongFromQueue_SongDeleted_DeletingFromTheMiddle()
var refSongsOrder = new List<Song> { songs[0], songs[1], songs[3], songs[4] };
var actualSongs = await GetQueueSongs();

Assert.True(Helpers.Helpers.EntityExistsInDatabase(songs[2], _context));
Assert.True(Helpers.EntityExistsInDatabase(songs[2], _context));
CollectionAssert.AreEqual(refSongsOrder, actualSongs);
CollectionAssert.DoesNotContain(await GetQueueSongs(),songs[2]);
}

[Test]
public async Task GetQueueInfo_InformationRetrieved()
{
var mapper = Helpers.Helpers.GenerateMapper();
var mapper = Helpers.GenerateMapper();

await PopulateQueueWithSongs();

Expand Down Expand Up @@ -187,7 +186,7 @@ private List<Song> GenerateSongs(int count)
var songs = SongGenerator.GenerateSongs
(
new List<MusicUser> {_musicUser},
GenreGenerator.GenerateSongGenres(Helpers.Helpers.Constants.SingleEntity),
GenreGenerator.GenerateSongGenres(Helpers.Constants.SingleEntity),
count
).ToList();

Expand All @@ -202,9 +201,9 @@ private ListeningQueueInfoDto GenerateRefDto()
return new ListeningQueueInfoDto(_musicUser.Id, new List<SongInfoDto>()
{
new (_firstSong.Name, _firstSong.Genre.Name, _firstSong.Author.Name, _firstSong.ContentUri,
_firstSong.SharedForCommunity, _firstSong.CoverUri),
_firstSong.CoverUri),
new (_secondSong.Name, _secondSong.Genre.Name, _secondSong.Author.Name, _secondSong.ContentUri,
_firstSong.SharedForCommunity, _secondSong.CoverUri)
_secondSong.CoverUri)
});
}
}
Loading

0 comments on commit 2742613

Please sign in to comment.