Esempio n. 1
0
        public AddEmailHeaderView(EmailHeaderModel emailHeader)
        {
            InitializeComponent();
            DataContext = ViewModel = new AddEmailHeaderViewModel(emailHeader);
            ViewModel.PropertyChanged += ViewModelOnPropertyChanged;

            Owner = Application.Current.MainWindow;
        }
Esempio n. 2
0
        public AddEmailHeaderViewModel(EmailHeaderModel emailHeader)
        {
            var dataUnitLocator = ContainerAccessor.Instance.GetContainer().Resolve<IDataUnitLocator>();
            _adminDataUnit = dataUnitLocator.ResolveDataUnit<IAdminDataUnit>();

            SaveCommand = new RelayCommand(SaveCommandExecuted, SaveCommandCanExecute);
            CancelCommand = new RelayCommand(CancelCommandExecuted);
            AddHeaderImageCommand = new RelayCommand(AddHeaderImageCommandExecuted);

            ProcessHeader(emailHeader);
        }
Esempio n. 3
0
        private void ProcessHeader(EmailHeaderModel emailHeader)
        {
            _isEdit = emailHeader != null;
            EmailHeader = _isEdit ? emailHeader : GetNewHeader();

            if (_isEdit)
            {
                var appPath = (string)ApplicationSettings.Read("ImagesPath");
                if (!string.IsNullOrWhiteSpace(appPath))
                    EmailHeader.HeaderImageUrl = string.Concat(appPath, _emailHeader.ImageName);
            }
            EmailHeader.PropertyChanged += EmailHeaderViewModel_PropertyChanged;
        }
Esempio n. 4
0
        private void EditEmailHeaderCommandExecuted(EmailHeaderModel emailHeader)
        {
            RaisePropertyChanged("DisableParentWindow");

            var view = new AddEmailHeaderView(emailHeader);
            view.ShowDialog();

            RaisePropertyChanged("EnableParentWindow");
            if (view.DialogResult != null && view.DialogResult == true)
            {
                _adminDataUnit.EmailHeadersRepository.Refresh();
            }
        }
Esempio n. 5
0
        private void DeleteEmailHeaderCommandExecuted(EmailHeaderModel emailHeader)
        {
            if (emailHeader == null) return;

            RaisePropertyChanged("DisableParentWindow");

            bool? dialogResult = null;
            string confirmText = Properties.Resources.MESSAGE_ASK_BEFORE_DELETING_ITEM;

            RadWindow.Confirm(confirmText, (sender, args) => { dialogResult = args.DialogResult; });

            RaisePropertyChanged("EnableParentWindow");

            if (dialogResult != true) return;

            _adminDataUnit.EmailHeadersRepository.Delete(emailHeader.EmailHeader);

            _adminDataUnit.SaveChanges();

            AllEmailHeaders.Remove(emailHeader.EmailHeader);

            RefreshEmailHeaders();
        }