Esempio n. 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
            }));
        }