public ActionResult <IEnumerable <BandDto> > CreateBands(IEnumerable <CreateBandDto> bandDtos) { var bands = _mapper.Map <IEnumerable <Band> >(bandDtos); _repository.AddBands(bands); _repository.Save(); var ids = string.Join(",", bands.Select(b => b.Id)); var bandCollectionToReturn = _mapper.Map <IEnumerable <BandDto> >(bands); return(CreatedAtRoute("GetBandsCollection", new { ids = ids }, bandCollectionToReturn)); }
public async Task <ActionResult <IEnumerable <BandDto> > > CreateBandCollection([FromBody] IEnumerable <BandForCreatingDto> bandCollection) { var bandsEntities = _mapper.Map <IEnumerable <Band> >(bandCollection); _bandAlbumRepository.AddBands(bandsEntities); await _bandAlbumRepository.Save(); // Select Method // bandsEntities.Select(b => b.Id); // Linq // from b in bandsEntities select b.Id var bandsToReturn = _mapper.Map <IEnumerable <BandDto> >(bandsEntities); return(CreatedAtRoute("GetBandsByIds", new { bandIds = from b in bandsToReturn select b.Id }, bandsToReturn)); }