コード例 #1
0
        public async Task <IActionResult> SelectKit(PsBranchSelection branchSelection)
        {
            var settings = await _performerSchedulingService.GetSettingsAsync();

            var schedulingStage = _performerSchedulingService.GetSchedulingStage(settings);

            if (schedulingStage != PsSchedulingStage.SchedulingOpen)
            {
                return(RedirectToAction(nameof(Index)));
            }

            PsBranchSelection addedBranchSelection = null;

            try
            {
                addedBranchSelection = await _performerSchedulingService
                                       .AddBranchKitSelectionAsync(branchSelection);

                _logger.LogInformation("Kit selection: {BranchSelectionId} added by user {UserId}",
                                       addedBranchSelection.Id,
                                       GetId(ClaimType.UserId));

                ShowAlertSuccess("Kit selection added!");
            }
            catch (GraException gex)
            {
                ShowAlertDanger($"Unable to select kit: ", gex);
            }

            if (branchSelection?.KitId != null)
            {
                return(RedirectToAction(nameof(Kit), new { id = branchSelection.KitId }));
            }
            else
            {
                return(RedirectToAction(nameof(Kits)));
            }
        }