Ejemplo n.º 1
6
        private void AddNewContact(object param)
        {
            var modalWindow = _container.Resolve<IModalWindow>();

            var contactVm = ContactViewModel.GetViewModelForNewContact();

            var vmValidator = new ViewModelValidator();

            vmValidator.AddRule(() => contactVm.FirstName,
                                () => RuleResult.Assert(!string.IsNullOrEmpty(contactVm.FirstName), Resources.ShellViewModel_AddNewContact_First_Name_is_required));

            vmValidator.AddRule(() => contactVm.LastName,
                               () => RuleResult.Assert(!string.IsNullOrEmpty(contactVm.LastName), Resources.ShellViewModel_AddNewContact_Last_Name_is_required));

            contactVm.Validator = vmValidator;

            var viewModel = new AddOrViewContactViewModel(contactVm, true);
            var dialogService = _container.Resolve<IModalDialogService>();

            var dialogResult = dialogService.ShowDialog(modalWindow, viewModel);
            if (dialogResult.HasValue && dialogResult.Value)
                _contactList.Add(viewModel.Contact);
        }
Ejemplo n.º 2
0
        private void ViewContactDetails(object param)
        {
            var modalWindow = _container.Resolve<IModalWindow>();

            var vmValidator = new ViewModelValidator();
            vmValidator.AddRule(() => CurrentContact.FirstName,
                                () => RuleResult.Assert(!string.IsNullOrEmpty(CurrentContact.FirstName), Resources.ShellViewModel_AddNewContact_First_Name_is_required));

            vmValidator.AddRule(() => CurrentContact.LastName,
                               () => RuleResult.Assert(!string.IsNullOrEmpty(CurrentContact.LastName), Resources.ShellViewModel_AddNewContact_Last_Name_is_required));

            CurrentContact.Validator = vmValidator;

            var viewModel = new AddOrViewContactViewModel(CurrentContact, false);
            var dialogService = _container.Resolve<IModalDialogService>();

            dialogService.ShowDialog(modalWindow, viewModel);
        }