public ActionResult <BandDto> CreateBand([FromBody] BandForCreatingDto band) { var bandEntity = _mapper.Map <entities.Band>(band); _bandAlbumResponsitory.AddBand(bandEntity); _bandAlbumResponsitory.Save(); var bandToReturn = _mapper.Map <BandDto>(bandEntity); return(CreatedAtRoute("GetBand", new { bandId = bandToReturn.Id }, bandToReturn)); }
public ActionResult <IEnumerable <BandDto> > CreateBandCollection([FromBody] IEnumerable <BandForCreatingDto> bandCollection) { var bandEntities = _mapper.Map <IEnumerable <entities.Band> >(bandCollection); foreach (var band in bandEntities) { _bandAlbumResponsitory.AddBand(band); } _bandAlbumResponsitory.Save(); var bandCollectionToReturn = _mapper.Map <IEnumerable <BandDto> >(bandEntities); var IdsString = string.Join(",", bandCollectionToReturn.Select(a => a.Id)); return(CreatedAtRoute("GetBandCollection", new { ids = IdsString }, bandCollectionToReturn)); }