コード例 #1
0
        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));
        }
コード例 #2
0
        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()));
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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);
        }
コード例 #5
0
        public PlaylistDto CreateAndRetrievePlaylist(CreatePlaylistDto dto)
        {
            var playlistId = CreatePlaylist(dto);

            return(new PlaylistDto(playlistId, dto));
        }
コード例 #6
0
 public long CreatePlaylist(CreatePlaylistDto dto)
 {
     return(playlistRepository.CreateVideoSequence(dto));
 }