Example #1
0
        public async Task <GetEditionForEditOutput> GetEditionForEdit(NullableIdInput input)
        {
            EditionEditDto          editionEditDto;
            List <NameValue>        list;
            IReadOnlyList <Feature> all = this.FeatureManager.GetAll();

            if (!input.Id.HasValue)
            {
                editionEditDto = new EditionEditDto();
                IReadOnlyList <Feature> features = all;
                list = (
                    from f in features
                    select new NameValue(f.Name, f.DefaultValue)).ToList <NameValue>();
            }
            else
            {
                EditionManager editionManager = this._editionManager;
                int?           id             = input.Id;
                Edition        edition        = await editionManager.FindByIdAsync(id.Value);

                EditionManager editionManager1 = this._editionManager;
                id = input.Id;
                IReadOnlyList <NameValue> featureValuesAsync = await editionManager1.GetFeatureValuesAsync(id.Value);

                list           = featureValuesAsync.ToList <NameValue>();
                editionEditDto = edition.MapTo <EditionEditDto>();
                edition        = null;
            }
            GetEditionForEditOutput getEditionForEditOutput = new GetEditionForEditOutput()
            {
                Edition = editionEditDto
            };
            List <FlatFeatureDto> flatFeatureDtos = all.MapTo <List <FlatFeatureDto> >();

            getEditionForEditOutput.Features = (
                from f in flatFeatureDtos
                orderby f.DisplayName
                select f).ToList <FlatFeatureDto>();
            List <NameValue> nameValues = list;

            getEditionForEditOutput.FeatureValues = (
                from fv in nameValues
                select new NameValueDto(fv)).ToList <NameValueDto>();
            return(getEditionForEditOutput);
        }