Ejemplo n.º 1
0
        public AddCampaignView(CampaignModel model)
        {
            InitializeComponent();
            DataContext = ViewModel = new AddCampaignViewModel(model);

            Owner = Application.Current.MainWindow;
            Loaded += OnAddCampaignViewLoaded;
        }
Ejemplo n.º 2
0
        public AddCampaignViewModel(CampaignModel campaignModel)
        {
            var dataUnitLocator = ContainerAccessor.Instance.GetContainer().Resolve<IDataUnitLocator>();
            _crmDataUnit = dataUnitLocator.ResolveDataUnit<ICrmDataUnit>();

            SubmitCommand = new RelayCommand(SubmitCommandExecuted, SubmitCommandCanExecute);
            CancelCommand = new RelayCommand(CancelCommandExecuted);

            ProcessCampaign(campaignModel);
        }
Ejemplo n.º 3
0
        private void ProcessCampaign(CampaignModel campaignModel)
        {
            _isEditMode = (campaignModel != null);

            if (_isEditMode)
            {
                CampaignType = campaignModel.CampaignType;
            }

            Campaign = (_isEditMode) ? campaignModel : GetCampaign();
            Campaign.PropertyChanged += CampaignOnPropertyChanged;
        }
Ejemplo n.º 4
0
        public async void LoadData()
        {
            IsBusy = true;

            var types = await _crmDataUnit.CampaignTypesRepository.GetAllAsync();
            CampaignTypes = new ObservableCollection<CampaignType>(types.OrderBy(x => x.Name));

            if (_isEditMode)
            {
                var desiredCampaign = await _crmDataUnit.CampaignsRepository.GetUpdatedCampaign(_campaign.Campaign.ID);

                // Check if we have new changes
                if (desiredCampaign != null && desiredCampaign.LastEditDate != null && _campaign.LoadedTime < desiredCampaign.LastEditDate)
                {
                    Campaign = new CampaignModel(desiredCampaign);
                    CampaignType = desiredCampaign.CampaignType;
                }
            }

            IsBusy = false;
        }
Ejemplo n.º 5
0
        private CampaignModel GetCampaign()
        {
            var campaign = new CampaignModel(new Campaign()
            {
                ID = Guid.NewGuid(),               
                StartDate = DateTime.Now,
                EndDate = DateTime.Now.AddDays(1),
                IsActive = true
            });

            return campaign;
        }
Ejemplo n.º 6
0
        private void EditCampaignCommandExecute(CampaignModel item)
        {
            RaisePropertyChanged("DisableParentWindow");

            var window = new AddCampaignView(item);
            window.ShowDialog();

            RaisePropertyChanged("EnableParentWindow");

            item.Refresh();
        }