public ActionResult <Band_Dto> CreateBand([FromBody] BandForCreating_Dto newband) { var bandEntity = _mapper.Map <Entities.m_cls_Band>(newband); // Profiles _bandAlbumRepository.AddBand(bandEntity); _bandAlbumRepository.Save(); var bandToReturn = _mapper.Map <Band_Dto>(bandEntity); // redirect to GetBand route (Name = GetBand) return(CreatedAtRoute("GetBand", new { bandId = bandToReturn.Id }, bandToReturn)); }
public ActionResult <IEnumerable <BandDto> > CreateBandCollection([FromBody] IEnumerable <BandForCreatingDto> bandCollection) { var bandEntities = _mapper.Map <IEnumerable <Band> >(bandCollection); foreach (var band in bandEntities) { _repository.AddBand(band); } _repository.Save(); var bandCollectionToReturn = _mapper.Map <IEnumerable <BandDto> >(bandEntities); var IdsString = string.Join(",", bandCollectionToReturn.Select(a => a.Id)); return(CreatedAtRoute("GetBandCollection", new { ids = IdsString }, bandCollectionToReturn)); }
public ActionResult <IEnumerable <BandDto> > CreateColletion([FromBody] IEnumerable <BandForCreatingDto> _bands) { var BandEntity = _mapper.Map <IEnumerable <Band> >(_bands); foreach (var Band in BandEntity) { _bandAlbumRepository.AddBand(Band); } _bandAlbumRepository.Save(); var bandsCreating = _mapper.Map <IEnumerable <BandDto> >(BandEntity); return(Ok(bandsCreating)); }
public ActionResult <BandDto> CreateBand([FromBody] BandForCreatingDto band) { var bandEntity = _mapper.Map <Band>(band); if (bandEntity == null) { return(BadRequest("Band is Empty")); } _bandAlbumRepository.AddBand(bandEntity); _bandAlbumRepository.Save(); var bandToReturn = _mapper.Map <BandDto>(bandEntity); return(CreatedAtRoute(nameof(GetBand), new { bandId = bandToReturn.Id }, bandToReturn)); }
public ActionResult <IEnumerable <Band> > CreateAGroupOfBandsAtAGo(IEnumerable <BandCreationDto> bandCreationDtos) { var bandsToCreate = _mapper.Map <IEnumerable <Band> >(bandCreationDtos); foreach (var band in bandsToCreate) { _bandAlbumRepository.AddBand(band); } _bandAlbumRepository.Save(); var bandsToReturn = _mapper.Map <IEnumerable <BandDto> >(bandsToCreate); var ids = string.Join(",", bandsToReturn.Select(x => x.Id)); return(CreatedAtRoute("GetCollectionOfBands", new { ids }, bandsToReturn)); }
public ActionResult <BandDto> CreateBand([FromBody] BandForCreatingDto band) { var bandEntity = _mapper.Map <Entities.Band>(band); _bandAlbumRepository.AddBand(bandEntity); _bandAlbumRepository.Save(); var bandToReturn = _mapper.Map <BandDto>(bandEntity); var links = CreateLinksForBand(bandToReturn.Id, null); var linkedResourceToReturn = bandToReturn.ShapeData(null) as IDictionary <string, object>; linkedResourceToReturn.Add("links", links); return(CreatedAtRoute("GetBand", new { bandId = linkedResourceToReturn["Id"] }, linkedResourceToReturn)); }