コード例 #1
0
        public async Task OnPost([FromForm] ItemWrapperViewModel interactionModelSectionItemViewModel)
        {
            string className = interactionModelSectionItemViewModel.SelectedDialogItemType;
            Type   type      = Type.GetType($"{@namespace}.{className}, {assemblyName}");

            interactionModelSectionItemViewModel.DialogItem = DialogItemViewModelFactory.GetViewModel((BaseDialogItem)Activator.CreateInstance(type));

            DialogItem = interactionModelSectionItemViewModel.DialogItem;
        }
コード例 #2
0
        public async Task OnPostUpdate([FromForm] ItemWrapperViewModel interactionModelSectionItemViewModel)
        {
            string className = interactionModelSectionItemViewModel.SelectedDialogItemType;
            Type   type      = Type.GetType($"{@namespace}.{className}, {assemblyName}");

            if (interactionModelSectionItemViewModel.DialogItem == null)
            {
                interactionModelSectionItemViewModel.DialogItem = DialogItemViewModelFactory.GetViewModel((BaseDialogItem)TempData.Get(interactionModelSectionItemViewModel.SelectedDialogItemType, type));
            }

            DialogItem = interactionModelSectionItemViewModel.DialogItem ?? DialogItemViewModelFactory.GetViewModel(Database.HemaDialogItem);
        }
コード例 #3
0
        public void Test1()
        {
            var hemaDialogItem = new HemaDialogItem()
            {
                Name = "HemaItem", ResponseNoPackages = "No packages found.", HemaStatuses = statusMaps
            };

            var model  = new BaseDialogItemViewModel();
            var model2 = DialogItemViewModelFactory.GetViewModel(hemaDialogItem);
            //var model2 = new BaseDialogItemViewModel();
            //var model3 = new HemaDialogItemViewModel(new HemaDialogItem() { Name = "HemaItem", ResponseNoPackages = "No packages found.", HemaStatuses = statusMaps });

            var item  = model.ToDialogItem();
            var item2 = model2.ToDialogItem();
            //var item3 = model3.ToDialogItem(nameof(HemaDialogItem));
        }
コード例 #4
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;
        }