예제 #1
0
        public async Task <FieldSettingsViewModel> FillFailedSettingsModel(FieldSettingsViewModel model)
        {
            var project = await ProjectRepository.GetProjectWithFieldsAsync(CurrentProject.ProjectId);

            if (project == null)
            {
                return(null);
            }
            return(FillSettingsModel(project, model));
        }
예제 #2
0
 /// <summary>
 /// Set settings
 /// </summary>
 public async Task SettingsHandleAsync(FieldSettingsViewModel viewModel)
 {
     await Service.SetFieldSettingsAsync(new FieldSettingsRequest()
     {
         DescriptionField   = viewModel.DescriptionField > 0 ? viewModel.DescriptionField : (int?)null,
         NameField          = viewModel.NameField > 0 ? viewModel.NameField : (int?)null,
         LegacyModelEnabled = viewModel.LegacyModelEnabled,
         ProjectId          = CurrentProject.ProjectId,
     });
 }
예제 #3
0
        public async Task <ActionResult> Settings(FieldSettingsViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                return(await ViewIfFound(Manager.FillFailedSettingsModel(viewModel)));
            }
            try
            {
                await Manager.SettingsHandleAsync(viewModel);

                return(ReturnToIndex());
            }
            catch (Exception exception)
            {
                ModelState.AddException(exception);
                return(View(await Manager.FillFailedSettingsModel(viewModel)));
            }
        }
예제 #4
0
        /// <summary>
        /// Page with field settings
        /// </summary>
        public async Task <FieldSettingsViewModel> SettingsPagesAsync()
        {
            var project = await ProjectRepository.GetProjectWithFieldsAsync(CurrentProject.ProjectId);

            if (project == null)
            {
                return(null);
            }

            var viewModel = new FieldSettingsViewModel
            {
                NameField          = project.Details.CharacterNameField?.ProjectFieldId ?? -1,
                DescriptionField   = project.Details.CharacterDescription?.ProjectFieldId ?? -1,
                LegacyModelEnabled = project.Details.CharacterNameLegacyMode,
            };

            return(FillSettingsModel(project, viewModel));
        }
예제 #5
0
        private FieldSettingsViewModel FillSettingsModel(Project project, FieldSettingsViewModel viewModel)
        {
            var fields = project.GetOrderedFields();

            viewModel.PossibleDescriptionFields =
                ToSelectListItems(
                    fields.Where(f => f.FieldType == ProjectFieldType.Text && f.FieldBoundTo == FieldBoundTo.Character),
                    "Нет поля с описанием персонажа"
                    ).SetSelected(project.Details.CharacterDescription?.ProjectFieldId);
            viewModel.PossibleNameFields =
                ToSelectListItems(
                    fields.Where(f => f.FieldType == ProjectFieldType.String && f.FieldBoundTo == FieldBoundTo.Character),
                    "Имя персонажа берется из имени игрока"
                    ).SetSelected(project.Details.CharacterNameField?.ProjectFieldId);

            // cast needed to call correct method
            var _ = FillFromProject(project, viewModel);

            return(viewModel);
        }