Exemplo n.º 1
0
        protected virtual void OnSaveEventHandler(VmOnSave obj)
        {
            var data = obj.GetRow <T>();

            VmData.Add(data);
            SaveToRepository(obj);
            ViewState.HasPendingCommits = true;
        }
Exemplo n.º 2
0
        protected virtual void SaveCollection(SaveModeArgs obj)
        {
            obj.SetRow(_selectedItem);
            if (ViewService.ViewMode.Peek() == FormMode.SAVED)
            {
                var mode = ViewService.ViewMode.Pop();
                if (mode == FormMode.ADDMODE)
                {
                    AddToCollection(null);
                }
                //if we save then add

                return;
            }
            ValidationResult validation = ValidateVm();

            if (validation.IsValid)
            {
                if (!DataStoreContainsDuplicates(obj))
                {
                    if (ViewService.ViewMode.Peek() == FormMode.VALIDATION)
                    {
                        ViewService.ViewMode.Pop();
                    }
                    IsReadOnly = true;
                    VmData.Add(_selectedItem);
                    DoSave(obj);
                    //drop wip and then add saved

                    if (ViewService.ViewMode.Peek() == FormMode.SAVED)
                    {
                        ViewService.ViewMode.Pop();
                        ViewService.IsDirty = true;
                    }

                    if (ViewService.ViewMode.Peek() == FormMode.WIP)
                    {
                        ViewService.ViewMode.Pop();
                    }
                }

                else
                {
                    if (ViewService.ViewMode.Peek() != FormMode.WIP)
                    {
                        SendMessageBox("Duplicate Error Warning", "Duplicates not allowed");
                    }
                    IsReadOnly = false;
                }
            }
            else
            {
                var msg = new ValidationArgs();
                msg.Validation = validation.ErrorList;
                eventAggregator.GetEvent <ValidationArgsEvent>().Publish(msg);
            }
        }