Exemplo n.º 1
0
        public void ChildVM_To_BaseEntity_WithRedirectViaToDialogItem()
        {
            var childvm = new ChildVM(new Child()
            {
                Name  = "__child",
                Hobby = "__hobby",
                Age   = 8,
            });

            var withMappingVM = new BackendClassContainingMappingVM(new WithMapping(new List <Mapping>()
            {
                Mapping.Create("key123", "value123")
            })
            {
                Name  = "__backend",
                Hobby = "__mapping",
                Age   = 8,
            });

            BaseDialogItem child = childvm.ToDialogItem();

            Assert.IsType <Child>(child);

            Parent parent = childvm.Map();

            WithMapping backend      = withMappingVM.Map();
            Child       backendChild = withMappingVM.Map();

            Assert.True(backend.Mappings.Count == 1);
            Assert.True(backend.Mappings[0].Key == "key123");
        }
Exemplo n.º 2
0
        public static BaseDialogItemViewModel GetViewModel(BaseDialogItem dialogItem)
        {
            BaseDialogItemViewModel viewModel = dialogItem switch
            {
                HemaDialogItem c => c.ToViewModel <HemaDialogItemViewModel>(),
                _ => dialogItem.ToViewModel <BaseDialogItemViewModel>(),
            };

            //viewModel.ActualType = viewModel.GetType().AssemblyQualifiedName;
            return(viewModel);
        }
Exemplo n.º 3
0
        //public InteractionModelSectionItemViewModel(IEnumerable<BaseDialogItem> dialogItems) : this(null, dialogItems) { }
        //public InteractionModelSectionItemViewModel(InteractionModelSectionItem item) : this(item, null) { }
        public ItemWrapperViewModel(BaseDialogItem item) : base(item)
        {
            if (item != null)
            {
                InteractionModelSectionId = item.InteractionModelSectionId;
                DialogItemId = item.Id;
                DialogItem   = DialogItemViewModelFactory.GetViewModel(item);
                //Ordering = item.Ordering;
                //Enabled = item.Enabled;
            }

            foreach (var dialogItem in Database.DialogItemTypes.Select(s => s.Key))
            {
                DialogItemTypes.Add(new SelectListItem()
                {
                    Value    = dialogItem.Name,
                    Text     = dialogItem.Name.Replace("DialogItem", string.Empty),
                    Selected = dialogItem.Name == item?.GetType().Name
                });
            }
            SelectedDialogItemType = DialogItemTypes.FirstOrDefault(d => d.Selected)?.Value;
        }
Exemplo n.º 4
0
 private void AddItem(BaseDialogItem item)
 {
     _items.Add(item);
     _itemCount++;
 }