Ejemplo n.º 1
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);
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Create(PerformenceCreateInputModel createInputModel)
        {
            if (this.ModelState.IsValid)
            {
                var user = await this.userManager.GetUserAsync(this.User);

                var viewModel = await this.performenceService.CreatePerformence(createInputModel, user);

                return(this.Redirect(Common.GlobalConstants.HomeUrl));
            }

            return(View());
        }