Exemplo n.º 1
0
        public static FieldViewModel Create(BLL.Field field, string tabId, int parentId)
        {
            var viewModel             = Create <FieldViewModel>(field, tabId, parentId);
            var allVeStylesAndFormats = SiteService.GetAllVeStyles().ToList();

            viewModel.ActiveVeCommands = viewModel.Data.ActiveVeCommandIds.Select(c => new QPCheckedItem {
                Value = c.ToString()
            }).ToList();
            viewModel.DefaultCommandsListItems = FieldService.GetDefaultVisualEditorCommands().Select(c => new ListItem {
                Value = c.Id.ToString(), Text = c.Alias
            }).ToArray();
            viewModel.AllStylesListItems = allVeStylesAndFormats.Where(s => s.IsFormat == false).Select(x => new ListItem {
                Value = x.Id.ToString(), Text = x.Name
            }).ToArray();
            viewModel.AllFormatsListItems = allVeStylesAndFormats.Where(s => s.IsFormat).Select(x => new ListItem {
                Value = x.Id.ToString(), Text = x.Name
            }).ToArray();
            viewModel.ActiveVeStyles = allVeStylesAndFormats.Where(s => s.IsFormat == false && viewModel.Data.ActiveVeStyleIds.Contains(s.Id)).Select(x => new QPCheckedItem {
                Value = x.Id.ToString()
            }).ToList();
            viewModel.ActiveVeFormats = allVeStylesAndFormats.Where(s => s.IsFormat && viewModel.Data.ActiveVeStyleIds.Contains(s.Id)).Select(x => new QPCheckedItem {
                Value = x.Id.ToString()
            }).ToList();
            viewModel.DefaultArticleIds       = viewModel.Data.DefaultArticleIds;
            viewModel.DefaultArticleListItems = viewModel.Data.DefaultArticleListItems;
            viewModel.Init();
            return(viewModel);
        }