public async Task <IActionResult> CreatePlaylistForUser(string spotifyId, string timeFrame) { var user = (await _userRepository.CanContinueWithRequest(new Dictionary <string, string> { { "spotifyId", spotifyId }, { "timeFrame", timeFrame } })) .Match( some: u => u, none: () => null ); if (user == null) { return(BadRequest()); } var timeFrameObj = AsTimeFrame(timeFrame); // format the name for the playist to be created (i.e. "Four Week Top Tracks (07/31/2017 16:42:40)" ) CreatePlaylistDto requestContentDto = new CreatePlaylistDto { name = TimeFrameForPlaylistName(timeFrameObj) + " Top Tracks (" + DateTime.Now.ToString(CultureInfo.InvariantCulture) + ")" }; var requestContentString = JsonConvert.SerializeObject(requestContentDto); return(await MakePlaylistRequest(user, requestContentString, timeFrameObj)); }
public async Task <IActionResult> CreatePlaylist([FromBody] CreatePlaylistDto dto, CancellationToken token) { var command = new CreatePlaylistCommand { Name = dto.Name, UserId = dto.UserId }; await _mediator.Send(command, token); return(new JsonResult(Result.Ok())); }
public async Task <ActionResult <PlaylistCreationResult> > CreatePlaylist( [FromBody, Required] CreatePlaylistDto createPlaylistRequest) { var result = await _playlistManager.CreatePlaylist(new PlaylistCreationRequest { Name = createPlaylistRequest.Name, ItemIdList = createPlaylistRequest.Ids, UserId = createPlaylistRequest.UserId, MediaType = createPlaylistRequest.MediaType }).ConfigureAwait(false); return(result); }
public async Task CreatePlaylist_Succeeds_ReturnsSuccessResult() { var dto = new CreatePlaylistDto { Name = "Test", UserId = 1 }; var fakeMediator = A.Fake <IMediator>(); var controller = new PlaylistsController(fakeMediator); var json = (JsonResult)await controller.CreatePlaylist(dto, CancellationToken.None); var res = (Result)json.Value; Assert.IsTrue(res.Success); }
public PlaylistDto CreateAndRetrievePlaylist(CreatePlaylistDto dto) { var playlistId = CreatePlaylist(dto); return(new PlaylistDto(playlistId, dto)); }
public long CreatePlaylist(CreatePlaylistDto dto) { return(playlistRepository.CreateVideoSequence(dto)); }