public IActionResult GetBand(Guid bandId) { var bandFromRepo = _bandAlbumRepository.GetBand(bandId); if (bandFromRepo == null) { return(NotFound()); } return(Ok(bandFromRepo)); }
public IActionResult GetBand(Guid bandId) { var band = _repository.GetBand(bandId); if (band == null) { return(NotFound()); } return(Ok(band)); }
public IActionResult GetBand(Guid bandId) { var band = _bandAlbumRepository.GetBand(bandId); if (band == null) { return(StatusCode(StatusCodes.Status404NotFound)); } var bandDto = _mapper.Map <BandDto>(band); return(StatusCode(StatusCodes.Status200OK, bandDto)); }
public IActionResult GetBand(Guid bandId) { if (bandId == null) { return(BadRequest()); } Band band = _bandAlbumRepository.GetBand(bandId); if (band == null) { return(NotFound()); } return(Ok(band)); }
public IActionResult GetBand(Guid bandId, [FromQuery] string fields) { if (!_propertyValidationService.HasValidProperties <BandDto>(fields)) { return(BadRequest()); } Band band = _bandAlbumRepository.GetBand(bandId); if (band == null) { return(NotFound()); } return(Ok(_mapper.Map <BandDto>(band).ShapeData(fields))); }
public async Task <IActionResult> GetBand(Guid bandId, [FromQuery] string fields) { if (!_propertyValidationService.HasValidProperties <BandDto>(fields)) { return(BadRequest()); } var bandFromRepo = await _bandAlbumRepository.GetBand(bandId); if (bandFromRepo == null) { return(NotFound()); } return(Ok(_mapper.Map <BandDto>(bandFromRepo).ShapeData <BandDto>(fields))); }
public IActionResult getBand(Guid bandID, string fields) { if (!_propertyValidationService.HasValidParameters <BandDto>(fields)) { return(BadRequest()); } var bandFromRepo = _bandAlbumRepository.GetBand(bandID); if (bandFromRepo == null) { return(NotFound()); } return(new OkObjectResult(_mapper.Map <BandDto>(bandFromRepo).ShapeData(fields))); }
[HttpGet("{bandID}", Name = "GetBand")] //Not mentioning route here as attribute because all calls will direct to api/bands. //public IActionResult GetBand(int bandID) //IActionResult's implementation is a better choice. public ActionResult <BandDTO> GetBand(int bandID) //ActionResult is better to use because it specifies the output type. { var bandFromRepo = _bandAlbumRepository.GetBand(bandID); //Adding this because Ok() will return 200 OK or No Content even if the band isn't found. if (bandFromRepo == null) { return(NotFound()); } //return new JsonResult(bandFromRepo); Not using this because JsonResult would not be suitable for XML and other formats.. return(Ok(_mapper.Map <BandDTO>(bandFromRepo))); }
public IActionResult GetBand(Guid bandId, string fields) { if (!_propertyValidationService.HasValidProperties <BandDto>(fields)) { return(BadRequest()); } var bandFromRepo = _bandAlbumRepository.GetBand(bandId); if (bandFromRepo == null) { return(NotFound()); } var links = CreateLinksForBand(bandId, fields); var linkedResourceToReturn = _mapper.Map <BandDto>(bandFromRepo).ShapeData(fields) as IDictionary <string, object>; linkedResourceToReturn.Add("links", links); return(Ok(linkedResourceToReturn)); }
public ActionResult <BandDto> GetBand(Guid bandId) { var bandFromRepo = _bandAlbumRepository.GetBand(bandId); return(bandFromRepo == null?NotFound() : (ActionResult <BandDto>)Ok(_mapper.Map <BandDto>(bandFromRepo))); }
public IActionResult GetBand(Guid bandId) { var band = _bandAlbumRepository.GetBand(bandId); return(Ok(band)); }