예제 #1
0
        public async Task <IActionResult> Information()
        {
            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,
                                                                                        includeBranches : true);

            if (performer?.RegistrationCompleted == false)
            {
                return(RedirectToAction(nameof(Schedule)));
            }

            var systems = await _performerSchedulingService
                          .GetSystemListWithoutExcludedBranchesAsync();

            if (string.IsNullOrEmpty(settings.VendorIdPrompt))
            {
                settings.VendorIdPrompt = "Vendor ID";
            }

            var viewModel = new InformationViewModel
            {
                Performer   = performer,
                Settings    = settings,
                Systems     = systems,
                BranchCount = systems.Sum(_ => _.Branches.Count),
                MaxUploadMB = MaxUploadMB
            };

            if (performer != null)
            {
                if (performer.AllBranches)
                {
                    viewModel.BranchAvailability = systems
                                                   .SelectMany(_ => _.Branches)
                                                   .Select(_ => _.Id)
                                                   .ToList();
                }
                else
                {
                    viewModel.BranchAvailability = performer.Branches?.Select(_ => _.Id).ToList();
                }
            }

            PageTitle = "Performer Information";
            return(View(viewModel));
        }