Пример #1
0
        public SnoozeViewModel(EventReminderModel eventReminderModel)
        {
            EventReminder = eventReminderModel;

            OKCommand     = new RelayCommand(OKCommandExecute, OKCommandCanExecute);
            CancelCommand = new RelayCommand(CancelCommandExecute);
        }
Пример #2
0
        public void RefreshReminder(EventReminderModel eventReminder)
        {
            var radTabControl = RootGrid.Children[0] as RadTabControl;

            if (radTabControl != null)
            {
                var tabItem = radTabControl.Items[3] as RadTabItem;

                if (tabItem != null)
                {
                    var remindersView = tabItem.Content as RemindersView;
                    if (remindersView != null)
                    {
                        var remindersViewModel = remindersView.DataContext as RemindersViewModel;
                        if (remindersViewModel != null && remindersViewModel.EventReminders != null)
                        {
                            var reminder = remindersViewModel.EventReminders.FirstOrDefault(eReminder => eReminder.EventReminder.ID == eventReminder.EventReminder.ID);
                            if (reminder != null)
                            {
                                reminder.Refresh();
                            }
                        }
                    }
                }
            }
        }
Пример #3
0
        public AddEventReminderViewModel(IEnumerable <EventModel> events, EventReminderModel eventReminderModel)
        {
            var Today = DateTime.Now;

            Events = events.Where(x => x.Date.Date > Today.Date).OrderBy(x => x.Date).ThenBy(x => x.Name).ToList();

            var dataUnitLocator = ContainerAccessor.Instance.GetContainer().Resolve <IDataUnitLocator>();

            _eventDataUnit = dataUnitLocator.ResolveDataUnit <IEventDataUnit>();

            CanEditEveryoneEventReminders = AccessService.Current.UserHasPermissions(Resources.PERMISSION_EDIT_EVERYONE_FOLLOWUP_ALLOWED);
            CanEditOwnEventReminders      = AccessService.Current.UserHasPermissions(Resources.PERMISSION_EDIT_OWN_FOLLOWUP_ALLOWED);

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

            OpenEventCommand = new RelayCommand(OpenEventCommandExecute, OpenEventCommandCanExecute);
            if (eventReminderModel != null)
            {
                ProcessEventReminder(eventReminderModel);
                SelectedEvent  = Events.FirstOrDefault(x => x.Event == eventReminderModel.EventReminder.Event);
                _originalEvent = SelectedEvent.Clone();
            }
            else
            {
                EventReminder = GetEventReminderWithoutEvent();
                EventReminder.PropertyChanged += EventReminderOnPropertyChanged;
            }
        }
Пример #4
0
        public AddEventReminderView(List <EventModel> events, EventReminderModel eventReminder = null)
        {
            InitializeComponent();
            DataContext = ViewModel = new AddEventReminderViewModel(events, eventReminder);

            Owner = Application.Current.MainWindow;

            Loaded += OnAddEventReminderViewLoaded;
        }
Пример #5
0
        public ReminderPopUpView(EventReminderModel eventReminder)
        {
            InitializeComponent();
            DataContext = _viewModel = new ReminderPopUpViewModel(eventReminder);

            _viewModel.PropertyChanged += ViewModelOnPropertyChanged;

            Owner   = Application.Current.MainWindow;
            Loaded += OnFollowUpPopUpViewLoaded;
        }
Пример #6
0
 public AddEventReminderView(EventReminderModel eventReminder = null)
 {
     InitializeComponent();
     DataContext = ViewModel = new AddEventReminderViewModel(eventReminder);
     if (eventReminder != null)
     {
         this.Header = "Edit Event Reminder";
     }
     Owner   = Application.Current.MainWindow;
     Loaded += OnAddEventReminderViewLoaded;
 }
Пример #7
0
 private void ProcessEventReminder(EventReminderModel eventReminderModel)
 {
     IsEditMode = (eventReminderModel != null);
     if (IsEditMode)
     {
         CreatedByUser  = eventReminderModel.CreatedByUser;
         AssignedToUser = eventReminderModel.AssignedToUser;
     }
     EventReminder = (IsEditMode) ? eventReminderModel : GetEventReminder();
     EventReminder.PropertyChanged += EventReminderOnPropertyChanged;
 }
Пример #8
0
        private EventReminderModel GetEventReminderWithoutEvent()
        {
            var eventReminderModel = new EventReminderModel(new Data.Model.EventReminder()
            {
                ID              = Guid.NewGuid(),
                DateDue         = DateTime.Now,
                CreatedByUserID = AccessService.Current.User.ID,
                Status          = Convert.ToBoolean(Convert.ToInt32(EventManagementSystem.Enums.Events.ReminderStatus.Active))
            });

            return(eventReminderModel);
        }
Пример #9
0
        private void EditReminderCommandExecuted(EventReminderModel eventReminderModel)
        {
            RaisePropertyChanged("DisableParentWindow");
            var eventReminderView = new AddEventReminderView(eventReminderModel);

            eventReminderView.ShowDialog();

            if (eventReminderView.DialogResult != null && eventReminderView.DialogResult == true)
            {
                _eventDataUnit.SaveChanges();
            }
            RaisePropertyChanged("EnableParentWindow");
        }
Пример #10
0
        public ReminderPopUpViewModel(EventReminderModel eventReminderModel)
        {
            var dataUnitLocator = ContainerAccessor.Instance.GetContainer().Resolve <IDataUnitLocator>();

            _eventDataUnit = dataUnitLocator.ResolveDataUnit <IEventDataUnit>();

            EventReminder = eventReminderModel;

            SnoozeCommand                = new RelayCommand(SnoozeCommandExecute);
            OpenEventCommand             = new RelayCommand(OpenEventCommandExecuted, OpenEventCommandCanExecute);
            CompleteEventReminderCommand = new RelayCommand(CompleteEventReminderCommandExecuted);
            DeleteEventReminderCommand   = new RelayCommand(DeleteEventReminderCommandExecute);
        }
Пример #11
0
        public AddEventReminderViewModel(EventModel eventModel, EventReminderModel eventReminderModel)
        {
            _event = eventModel;
            var dataUnitLocator = ContainerAccessor.Instance.GetContainer().Resolve <IDataUnitLocator>();

            _eventDataUnit = dataUnitLocator.ResolveDataUnit <IEventDataUnit>();

            CanEditEveryoneEventReminders = AccessService.Current.UserHasPermissions(Resources.PERMISSION_EDIT_EVERYONE_FOLLOWUP_ALLOWED);
            CanEditOwnEventReminders      = AccessService.Current.UserHasPermissions(Resources.PERMISSION_EDIT_OWN_FOLLOWUP_ALLOWED);

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

            ProcessEventReminder(eventReminderModel);
        }
Пример #12
0
        private void EditEventReminderCommandExecuted(EventReminderModel eventReminderModel)
        {
            RaisePropertyChanged("DisableParentWindow");
            _originalEventReminder = eventReminderModel.Clone();
            var window = new AddEventReminderView(Event, eventReminderModel);

            window.ShowDialog();
            if (window.DialogResult != null && !window.DialogResult.Value)
            {
                eventReminderModel.EventReminder.DateDue          = _originalEventReminder.EventReminder.DateDue;
                eventReminderModel.EventReminder.WhatToDo         = _originalEventReminder.EventReminder.WhatToDo;
                eventReminderModel.EventReminder.AssignedToUserID = _originalEventReminder.EventReminder.AssignedToUserID;
                eventReminderModel.Refresh();
            }
            RaisePropertyChanged("EnableParentWindow");
        }
Пример #13
0
        public AddEventReminderViewModel(EventReminderModel eventReminderModel)
        {
            var dataUnitLocator = ContainerAccessor.Instance.GetContainer().Resolve <IDataUnitLocator>();

            _eventDataUnit = dataUnitLocator.ResolveDataUnit <IEventDataUnit>();

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

            if (eventReminderModel != null)
            {
                ProcessEventReminder(eventReminderModel);
            }
            else
            {
                EventReminder = GetEventReminderWithoutEvent();
                EventReminder.PropertyChanged += EventReminderOnPropertyChanged;
            }
        }
Пример #14
0
        private void AddDefaultEventReminderCommandExecuted()
        {
            if (Event.EventType.EventTypeTODOs.Any())
            {
                Event.EventType.EventTypeTODOs.ToList().ForEach(async eventTypeTODO =>
                {
                    var eventReminder = new EventReminderModel(new Data.Model.EventReminder()
                    {
                        ID               = Guid.NewGuid(),
                        EventID          = Event.Event.ID,
                        DateDue          = eventTypeTODO.RelatedDateType == Convert.ToInt32(EventManagementSystem.Enums.Admin.RelatedDateType.EventDate) ? Event.Date.AddDays(eventTypeTODO.NumberOfDays) : Event.Event.CreationDate.AddDays(eventTypeTODO.NumberOfDays),
                        CreatedByUserID  = AccessService.Current.User.ID,
                        WhatToDo         = eventTypeTODO.WhatToDo,
                        Status           = Convert.ToBoolean(Convert.ToInt32(EventManagementSystem.Enums.Events.ReminderStatus.Active)),
                        AssignedToUserID = eventTypeTODO.AssignedToUserID,
                        User             = eventTypeTODO.User1,
                        EventTypeToDoID  = eventTypeTODO.ID
                    });

                    Event.EventReminders.Add(eventReminder);
                    _eventDataUnit.EventRemindersRepository.Add(eventReminder.EventReminder);

                    var primaryContact = eventReminder.EventReminder.Event != null ? eventReminder.EventReminder.Event.Contact == null ? String.Empty : "Primary Contact: " + eventReminder.EventReminder.Event.Contact.FirstName + " "
                                         + eventReminder.EventReminder.Event.Contact.LastName : String.Empty;

                    var msg = "Default Event Reminder" + "\n" + "Created by " + eventReminder.CreatedByUser.FirstName + " " +
                              eventReminder.CreatedByUser.LastName + " at " + DateTime.Now + "\n" +
                              "Event Name: " + eventReminder.EventName + "\n" + primaryContact + "\n" + eventReminder.WhatToDo;
                    var email = new CorrespondenceModel(new Corresponcence()
                    {
                        ID          = Guid.NewGuid(),
                        Date        = DateTime.Now,
                        FromAddress = eventReminder.CreatedByUser.EmailAddress,
                        ToAddress   = eventReminder.AssignedToUser.EmailAddress,
                        Subject     = "Default Event Reminder",
                        Message     = msg,
                    });

                    await EmailService.SendEmail(email, null, null);
                });
            }
        }
Пример #15
0
        public void RefreshRemindersAfterAdding(EventReminderModel eventReminder)
        {
            var radTabControl = RootGrid.Children[0] as RadTabControl;

            var tabItem = radTabControl.Items[3] as RadTabItem;

            if (tabItem != null)
            {
                var remindersView = tabItem.Content as RemindersView;
                if (remindersView != null)
                {
                    var remindersViewModel = remindersView.DataContext as RemindersViewModel;
                    if (remindersViewModel != null && remindersViewModel.EventReminders != null)
                    {
                        remindersViewModel._allEventReminders.Add(eventReminder);
                        remindersViewModel.EventReminders = new System.Collections.ObjectModel.ObservableCollection <EventReminderModel>(remindersViewModel._allEventReminders.OrderBy(reminder => reminder.EventReminder.Status).ThenBy(reminder => reminder.DateDue));
                    }
                }
            }
        }
Пример #16
0
        private void DeleteReminderCommandExecuted(EventReminderModel eventReminderModel)
        {
            bool?  dialogResult = null;
            string confirmText  = Properties.Resources.MESSAGE_ASK_BEFORE_DELETING_ITEM;

            RaisePropertyChanged("DisableParentWindow");

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

            RaisePropertyChanged("EnableParentWindow");

            if (dialogResult != true)
            {
                return;
            }

            _eventDataUnit.EventRemindersRepository.Delete(eventReminderModel.EventReminder);
            _eventDataUnit.SaveChanges();
            EventReminders.Remove(eventReminderModel);
        }
Пример #17
0
        public async void LoadData()
        {
            IsBusy = true;

            var users = await _eventDataUnit.UsersRepository.GetUsersAsync();

            Users = new ObservableCollection <User>(users);

            OnLoadCurrentUser();

            if (IsEditMode)
            {
                var desiredEventReminder = await _eventDataUnit.EventRemindersRepository.GetUpdatedEventReminder(_eventReminder.EventReminder.ID);

                // Check if we have new changes
                if (desiredEventReminder != null && desiredEventReminder.LastEditDate != null && _eventReminder.LoadedTime < desiredEventReminder.LastEditDate)
                {
                    EventReminder  = new EventReminderModel(desiredEventReminder);
                    AssignedToUser = desiredEventReminder.User;
                }
            }
            IsBusy = false;
        }
Пример #18
0
        public void RemoveReminder(EventReminderModel eventReminder)
        {
            var radTabControl = RootGrid.Children[0] as RadTabControl;

            if (radTabControl != null)
            {
                var tabItem = radTabControl.Items[3] as RadTabItem;

                if (tabItem != null)
                {
                    var remindersView = tabItem.Content as RemindersView;
                    if (remindersView != null)
                    {
                        var remindersViewModel = remindersView.DataContext as RemindersViewModel;
                        if (remindersViewModel != null && remindersViewModel.EventReminders != null)
                        {
                            remindersViewModel._allEventReminders.RemoveAll(eReminder => eReminder.EventReminder.ID == eventReminder.EventReminder.ID);
                            remindersViewModel.EventReminders = new System.Collections.ObjectModel.ObservableCollection <EventReminderModel>(remindersViewModel._allEventReminders);
                        }
                    }
                }
            }
        }
Пример #19
0
 public SnoozeView(EventReminderModel eventReminder)
 {
     InitializeComponent();
     DataContext = _viewModel = new SnoozeViewModel(eventReminder);
 }