Example #1
0
        public async Task <ActionResult <Performence> > PostPerformence(Performence performence)
        {
            _context.Performence.Add(performence);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetPerformence", new { id = performence.id }, performence));
        }
Example #2
0
        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);
        }
Example #3
0
        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());
        }
Example #4
0
        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);
        }