Ejemplo n.º 1
0
        public async Task <ActionResult> GetArtistById(int id)
        {
            var response = new Response <ArtistResource>();

            if (id == 0)
            {
                response.status  = 400;
                response.message = "Artist Id cannot be 0";

                return(BadRequest(response));
            }

            var artist = await _artistService.GetArtistById(id);

            if (artist == null)
            {
                response.status  = 404;
                response.message = $"Artist with id: {id} does not exist";

                return(NotFound(response));
            }

            var artistResource = _mapper.Map <Artist, ArtistResource>(artist);

            response.status  = 200;
            response.message = "Artist retrieved successfully";
            response.data    = artistResource;

            return(Ok(response));
        }
Ejemplo n.º 2
0
        public async Task <ActionResult <ArtistResource> > GetArtistById(int id)
        {
            var artist = await _artistService.GetArtistById(id);

            var artistResource = _mapper.Map <Artist, ArtistResource>(artist);

            return(Ok(artistResource));
        }
Ejemplo n.º 3
0
        public async Task <ActionResult <ArtistRessource> > GetArtistById(int id)
        {
            try
            {
                var artist = await _artistService.GetArtistById(id);

                var artistRessource = _mapperService.Map <Artist, ArtistRessource>(artist);
                return(Ok(artistRessource));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
Ejemplo n.º 4
0
        public IActionResult Edit(Guid Id)
        {
            if (Id == null)
            {
                return(NotFound());
            }

            var artist = artistService.GetArtistById(Id);

            if (artist == null)
            {
                return(NotFound());
            }
            return(View(artist));
        }
Ejemplo n.º 5
0
        public async Task <ActionResult <ArtistResource> > CreateArtist([FromBody] SaveArtistResource saveArtistResource)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState)); // this needs refining, but for demo it is ok
            }
            var artistToCreate = _mapper.Map <Artist>(saveArtistResource);

            var newArtist = await _artistService.CreateArtist(artistToCreate);

            var artist = await _artistService.GetArtistById(newArtist.Id);

            var artistResource = _mapper.Map <ArtistResource>(artist);

            return(Ok(artistResource));
        }
Ejemplo n.º 6
0
        public IActionResult ShowArtist(int artistId)
        {
            SingleArtist model = new SingleArtist(artistsService.GetArtistById(artistId),
                                                  pictureService.GetAllPicsFromArtist(artistId), hRService.GetCityById((int)artistsService.GetArtistById(artistId).IdCity));

            return(View(model));
        }
        public async Task <IActionResult> Get(int id)
        {
            var artist = await _artistService.GetArtistById(id);

            var artistViewModel = artist.ToViewModel();

            return(Ok(artistViewModel));
        }
        public async Task <ActionResult <ArtistResource> > GETArtistById(int id)
        {
            try
            {
                Artist artist = await _serviceArtist.GetArtistById(id);

                if (artist == null)
                {
                    return(BadRequest("cet artist n'existe pas"));
                }
                ArtistResource artistResource = _mapperService.Map <Artist, ArtistResource>(artist);
                return(Ok(artistResource));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
Ejemplo n.º 9
0
        public async Task <IActionResult> Get(int id)
        {
            var artist = await _artistService.GetArtistById(id);

            if (artist == null)
            {
                return(NotFound());
            }
            return(Ok(artist));
        }
Ejemplo n.º 10
0
        public IActionResult ShowPicture(int picId)
        {
            var           pic   = pictureService.GetPicById(picId);
            SinglePicture model = new SinglePicture(pic);

            model.Picture.Artist    = artistService.GetArtistById(pic.IdArtist);
            model.Picture.Technique = pictureService.GetTechById(pic.IdTechnique);
            //var art = artistService.GetArtistById(pic.IdArtist);
            //var tech = pictureService.GetTechById(pic.IdTechnique);
            //SinglePicture model = new SinglePicture(pic, art, tech);
            return(View(model));
        }
Ejemplo n.º 11
0
        public async Task <ActionResult <IEnumerable <MusicResource> > > GetAllMusicsByArtistID(int id)
        {
            var artist = await _artistService.GetArtistById(id);

            if (artist == null)
            {
                return(NotFound());
            }
            var musics = await _musicService.GetMusicsByArtistId(id);

            var musicResources = _mapper.Map <IEnumerable <Music>, IEnumerable <MusicResource> >(musics);

            return(Ok(musicResources));
        }
Ejemplo n.º 12
0
 public IActionResult GetArtist(long id)
 {
     try
     {
         return(Json(_artistService.GetArtistById(id)));
     }
     catch (ArgumentException e)
     {
         return(NotFound(StatusCodes.Status404NotFound));
     }
     catch (Exception e)
     {
         return(StatusCode(StatusCodes.Status500InternalServerError));
     }
 }
Ejemplo n.º 13
0
 public IActionResult GetArtistById(long id)
 {
     try
     {
         return(Json(ArtistService.GetArtistById(id)));
     }
     catch (ArgumentException e)
     {
         log.LogError("An artist with the id :" + id + " does not exist." + e.Message);
         return(NotFound(StatusCodes.Status404NotFound));
     }
     catch (Exception e)
     {
         log.LogError("Something happened when retrieving an artist. " + e.Message);
         return(StatusCode(StatusCodes.Status500InternalServerError));
     }
 }
Ejemplo n.º 14
0
        public async Task <ActionResult <IEnumerable <MusicRessource> > > GetALlMusicByArtistID(int id)
        {
            var artist = await _artistService.GetArtistById(id);

            if (artist == null)
            {
                return(BadRequest("la artiste n'existe pas"));
            }
            var musics = await _musicServices.GetMusicsByArtistId(id);

            if (musics == null)
            {
                return(BadRequest("Les musics n'existe pas"));
            }
            // mappage
            var musicRessources = _mapperService.Map <IEnumerable <Music>, IEnumerable <MusicRessource> >(musics);

            return(Ok(musicRessources));
        }
Ejemplo n.º 15
0
 public Artist Get()
 {
     return(_service.GetArtistById(_query.Id));
 }
Ejemplo n.º 16
0
        public async Task <ActionResult <ArtistDTO> > GetArtistById(int id)
        {
            var artist = await _ArtistService.GetArtistById(id);

            return(Ok(artist));
        }
Ejemplo n.º 17
0
 public IActionResult GetArtistById(int id)
 {
     return(Ok(_artistService.GetArtistById(id)));
 }
Ejemplo n.º 18
0
 protected override Func <Artist> GetEntityById(long id)
 {
     return(() => _artistService.GetArtistById(id));
 }