コード例 #1
0
ファイル: ProcessController.cs プロジェクト: lvaiser/satia
        private async Task FillSelectLists(Process process, ProcessViewModel model)
        {
            foreach (var item in process.Fields)
            {
                switch (item.Type)
                {
                case FieldType.Gender:
                    model.Fields.Single(f => f.Type == item.Type.ToString()).SelectList = EnumHelper <Gender> .AsKeyValuePairs();

                    break;

                case FieldType.MaritalStatus:
                    model.Fields.Single(f => f.Type == item.Type.ToString()).SelectList = EnumHelper <MaritalStatus> .AsKeyValuePairs();

                    break;

                case FieldType.Country:
                    var countryList = new List <KeyValuePair <int, string> >();
                    var countries   = await this.CountryService.GetCountriesAsync();

                    foreach (Country country in countries)
                    {
                        countryList.Add(Mapper.Map <KeyValuePair <int, string> >(country));
                    }

                    model.Fields.Single(f => f.Type == item.Type.ToString()).SelectList = countryList;
                    break;

                default:
                    break;
                }
            }
        }