Ejemplo n.º 1
0
        public IActionResult CreateTrack(int albumId,
                                         [FromBody] TrackForCreationDto track)
        {
            if (track == null)
            {
                return(BadRequest());
            }

            if (!_albumInfoRepository.AlbumExists(albumId))
            {
                return(NotFound());
            }

            var finalTrack = Mapper.Map <Entities.Track>(track);

            _albumInfoRepository.AddTrackForAlbum(albumId, finalTrack);

            if (!_albumInfoRepository.Save())
            {
                return(StatusCode(500, "A problem happened while handling your request!"));
            }

            var createdTrack = Mapper.Map <Models.TrackDto>(finalTrack);

            return(CreatedAtRoute("GetTrack", new
                                  { albumId = albumId, trackId = createdTrack.Id }, createdTrack));
        }
Ejemplo n.º 2
0
        public IActionResult UpdateTrack(int albumId, int trackId,
                                         [FromBody] TrackForCreationDto track)
        {
            if (track == null)
            {
                return(BadRequest());
            }

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (!_albumInfoRepository.AlbumExists(albumId))
            {
                return(NotFound());
            }

            var trackEntity = _albumInfoRepository.GetTrackForAlbum(albumId, trackId);

            if (trackEntity == null)
            {
                return(NotFound());
            }

            Mapper.Map(track, trackEntity);

            if (!_albumInfoRepository.Save())
            {
                return(StatusCode(500, "A problem happened while handling your request!"));
            }

            return(NoContent());
        }
Ejemplo n.º 3
0
        public IActionResult AddTrack([FromForm] TrackForCreationDto track)
        {
            if (ModelState.IsValid)
            {
                if (track == null)
                {
                    return(BadRequest());
                }
                var trackEntity = Mapper.Map <Track_Members>(track);

                var artistId = (from a in _con.Artists where a.ApplicationUserId == stringId select a.Id).First();

                trackEntity.ArtistId     = artistId;
                trackEntity.TrackPathUrl = Upload(artistId);

                _trackRepo.AddTrack(trackEntity);

                if (!_trackRepo.Save())
                {
                    ViewBag.Notification("No User Created");
                }
            }
            return(View());
        }
Ejemplo n.º 4
0
        public IActionResult AddTrack()
        {
            var track = new TrackForCreationDto();

            return(View(track));
        }