Beispiel #1
0
        public override async void Add <TModel>(TModel model)
        {
            try
            {
                DictionaryDialogViewModel view = new DictionaryDialogViewModel();
                view.Title    = Configuration.DIC_ADD_TITLE;
                view.TypeList = (await ZFSBridge.BridgeFactory.BridgeManager.GetDictionaryTypeManager().GetDictionaryTypes()).Results;
                var dialog = ServiceProvider.Instance.Get <IModelDialog>("DictionaryViewDlg");
                dialog.BindViewModel(view);
                var taskResult = await dialog.ShowDialog(
                    null,
                    view.ExtendedClosingEventHandler);

                if (taskResult)
                {
                    view.Dictionary.CreatedBy    = Loginer.LoginerUser.UserName;
                    view.Dictionary.CreationDate = DateTime.Now;
                    var req = await ZFSBridge.BridgeFactory.BridgeManager.GetDictionaryManager().AddEntity(view.Dictionary);

                    if (req.Success)
                    {
                        GridModelList.Add(view.Dictionary);
                        Msg.Info(Configuration.ADD_MSG);
                    }
                }
            }
            catch (Exception ex)
            {
                Msg.Error(ex.Message, false);
            }
        }
Beispiel #2
0
        public override async void Edit <TModel>(TModel model)
        {
            if (!this.GetButtonAuth(Authority.EDIT))
            {
                return;
            }

            if (model != null)
            {
                try
                {
                    DictionaryDialogViewModel view = new DictionaryDialogViewModel();
                    view.Title      = Configuration.DIC_EDIT_TITLE;
                    view.Dictionary = model as tb_Dictionary;
                    view.TypeList   = (await ZFSBridge.BridgeFactory.BridgeManager.GetDictionaryTypeManager().GetDictionaryTypes()).Results;
                    var dialog = ServiceProvider.Instance.Get <IModelDialog>("DictionaryViewDlg");
                    dialog.BindViewModel(view);
                    var taskResult = await dialog.ShowDialog(
                        null,
                        view.ExtendedClosingEventHandler);

                    if (taskResult)
                    {
                        view.Dictionary.LastUpdatedBy  = Loginer.LoginerUser.UserName;
                        view.Dictionary.LastUpdateDate = DateTime.Now;
                        var dicSerivce = ZFSBridge.BridgeFactory.BridgeManager.GetDictionaryManager();
                        var req        = await dicSerivce.UpdateEntity(view.Dictionary);

                        if (req.Success)
                        {
                            var mod = GridModelList.FirstOrDefault(t => t.isid.Equals(view.Dictionary.isid));
                            GridModelList.Remove(mod);
                            GridModelList.Add(view.Dictionary);
                            Msg.Info(Configuration.UPDATE_MSG);
                        }
                    }
                }
                catch (Exception ex)
                { Msg.Error(ex.Message, false); }
            }
        }