public async Task <ActionResult <Performence> > PostPerformence(Performence performence) { _context.Performence.Add(performence); await _context.SaveChangesAsync(); return(CreatedAtAction("GetPerformence", new { id = performence.id }, performence)); }
public async Task <bool> CreatePerformence(PerformenceCreateInputModel inputModel, ApplicationUser user) { Performence performence = AutoMapper.Mapper.Map <Performence>(inputModel); if (performence == null) { return(false); } performence.ArtistId = user.ArtistId; var pictureName = performence.Id; var pictureUrl = await this.cloudinaryService.UploadPictureAsync(inputModel.PerformencePhoto, pictureName); performence.PerformencePhoto.Title = pictureName; performence.PerformencePhoto.Link = pictureUrl; performence.PerformencePhoto.Description = inputModel.Description; PictureInputModel picture = AutoMapper.Mapper.Map <PictureInputModel>(performence.PerformencePhoto); var pictureId = await this.fileService.AddPictureToDb(picture); performence.PerformencePhotoId = pictureId; await this.performenceRepository.AddAsync(performence); await this.performenceRepository.SaveChangesAsync(); bool result = await this.artistService.SetPerformenceAsync(user.ArtistId, performence); return(result); }
public async Task <IActionResult> PutPerformence(int id, Performence performence) { if (id != performence.id) { return(BadRequest()); } _context.Entry(performence).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PerformenceExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <bool> SetPerformenceAsync(string artistId, Performence performence) { var artist = this.GetArtistById(artistId); artist.Performences.Add(performence); this.artistRepository.Update(artist); var result = await this.artistRepository.SaveChangesAsync(); return(result > 0); }