Beispiel #1
0
        public async Task <JsonResult> ScheduleProgram(PsBranchSelection branchSelection)
        {
            var settings = await _performerSchedulingService.GetSettingsAsync();

            var schedulingStage = _performerSchedulingService.GetSchedulingStage(settings);

            if (schedulingStage != PsSchedulingStage.SchedulingOpen)
            {
                return(Json(new
                {
                    success = false,
                    message = "Program selection is not currently open."
                }));
            }

            try
            {
                var addedBranchSelection = await _performerSchedulingService
                                           .AddBranchProgramSelectionAsync(branchSelection);

                _logger.LogInformation("Program selection: {BranchSelectionId} added by user {UserId}",
                                       addedBranchSelection.Id,
                                       GetId(ClaimType.UserId));
            }
            catch (GraException gex)
            {
                return(Json(new
                {
                    success = false,
                    message = gex.Message
                }));
            }

            ShowAlertSuccess("Program selection added!");
            return(Json(new
            {
                success = true
            }));
        }
Beispiel #2
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)));
            }
        }