Ejemplo n.º 1
0
        public async Task <IActionResult> ProgramDetails(int id)
        {
            var settings = await _performerSchedulingService.GetSettingsAsync();

            var schedulingStage = _performerSchedulingService.GetSchedulingStage(settings);

            if (schedulingStage < PsSchedulingStage.RegistrationOpen)
            {
                return(RedirectToAction(nameof(Index)));
            }

            var userId    = GetId(ClaimType.UserId);
            var performer = await _performerSchedulingService.GetPerformerByUserIdAsync(userId);

            if (performer?.RegistrationCompleted != true)
            {
                return(RedirectToAction(nameof(Information)));
            }

            var program = await _performerSchedulingService.GetProgramByIdAsync(id,
                                                                                includeAgeGroups : true);

            if (program == null)
            {
                return(RedirectToAction(nameof(Dashboard)));
            }

            var viewModel = new ProgramDetailsViewModel
            {
                IsEditable = schedulingStage == PsSchedulingStage.RegistrationOpen,
                Program    = program
            };

            if (program.Images?.Count > 0)
            {
                viewModel.Image = _pathResolver.ResolveContentPath(
                    program.Images[0].Filename);
            }

            return(View(viewModel));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Details(int id)
        {
            var model = new ProgramDetailsViewModel
            {
                Program = await this.programs.ByIdAsync <ProgramDetailsServiceModel>(id)
            };

            if (model.Program == null)
            {
                return(NotFound());
            }

            if (User.Identity.IsAuthenticated)
            {
                var userId = this.userManager.GetUserId(User);

                model.UserIsEnrolledProgram =
                    await this.programs.UserIsEnrolledProgramAsync(id, userId);
            }

            return(View(model));
        }