コード例 #1
0
        public virtual JsonResult AgreementStatusOptions()
        {
            var comboBox = new ComboBoxOptions
            {
                strict      = false,
                buttonTitle = "Show examples",
                source      = DefaultStatuses.Select(text => new AutoCompleteOption {
                    label = text, value = text,
                }),
            };
            var configuration = _queryProcessor.Execute(new GetMyInstitutionalAgreementConfigurationQuery(User));

            if (configuration != null)
            {
                comboBox.source = configuration.AllowedStatusValues.OrderBy(o => o.Text).Select(o => o.Text)
                                  .Select(t => new AutoCompleteOption {
                    label = t, value = t,
                });
                comboBox.strict = !configuration.IsCustomStatusAllowed;
                if (comboBox.strict)
                {
                    comboBox.buttonTitle = "Select one";
                }
            }
            return(Json(comboBox, JsonRequestBehavior.AllowGet));
        }
コード例 #2
0
        public virtual ActionResult Add()
        {
            var model = new InstitutionalAgreementConfigurationForm();

            // find the configuration for the currently signed in user's default affiliation
            var configuration = _queryProcessor.Execute(new GetMyInstitutionalAgreementConfigurationQuery(User));

            // if configuration exists, cannot add
            if (configuration != null)
            {
                model = Mapper.Map <InstitutionalAgreementConfigurationForm>(configuration);
            }
            else
            {
                // when configuration does not exist, get the default affiliation for the currently signed in user
                var person = GetConfigurationSupervisor();
                if (person == null)
                {
                    return(HttpNotFound());
                }

                // allow the viewmodel to disclose the establishment official name
                model.ForEstablishmentOfficialName = person.DefaultAffiliation.Establishment.OfficialName;

                // add default options
                DefaultTypes.ForEach(option => model.AllowedTypeValues.Add(
                                         new InstitutionalAgreementTypeValueForm {
                    IsAdded = true, Text = option
                }));
                DefaultStatuses.ForEach(option => model.AllowedStatusValues.Add(
                                            new InstitutionalAgreementStatusValueForm {
                    IsAdded = true, Text = option
                }));
                DefaultContactTypes.ForEach(option => model.AllowedContactTypeValues.Add(
                                                new InstitutionalAgreementContactTypeValueForm {
                    IsAdded = true, Text = option
                }));

                // add a default empty allowed options
                AddEmptyAllowedOptions(model);
            }
            return(View(model));
        }