예제 #1
0
        public async Task <ActionResult <PlayList> > Put([FromRoute] Guid id, [FromBody] PlayListDTO model)
        {
            PlayList playList = _mapper.Map <PlayList>(model);
            PlayList response = await _playListService.UpdatePlayListAsync(id, playList);

            if (response == null)
            {
                return(BadRequest());
            }
            return(CreatedAtAction(nameof(Get), new { id = response.Id }, response));
        }
예제 #2
0
        public async Task <ActionResult <PlayList> > Post([FromBody] PlayListDTO model)
        {
            PlayList playList = _mapper.Map <PlayList>(model);
            var      user     = User.Claims.ToList();

            playList.UserId = Guid.Parse(user.FirstOrDefault(x => x.Type == "id").Value);
            var response = await _playListService.InsertPlayListAsync(playList);

            if (response == null)
            {
                return(BadRequest());
            }

            return(CreatedAtAction(nameof(Get), new { id = response.Id }, response));
        }
예제 #3
0
        public List <PlayListDTO> AllPlayLists()
        {
            //return _db.PlayLists.ToList();
            List <PlayListDTO> x = new List <PlayListDTO>();
            var play             = _db.PlayLists.ToList();

            foreach (PlayList q in play)
            {
                PlayListDTO temp = new PlayListDTO();
                temp.PlayListId   = q.Id;
                temp.PlayListName = q.PlayListName;
                x.Add(temp);
            }
            //x.PlayListId=play.Id
            return(x);
        }