Пример #1
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;
            }
        }
Пример #2
0
        //Edit event btn
        private void Edit_Click_1(object sender, RoutedEventArgs e)
        {
            UserEvent newUser = SelectedEvent.Clone();
            DateTime  dt      = new DateTime(EditEventDate.Year, EditEventDate.Month, EditEventDate.Day);
            TimeSpan  ts      = new TimeSpan(EditEventHour, EditEventMinute, 0);

            dt += ts;
            newUser.EventDate  = dt;
            newUser.EventTitle = EditEventTitle;
            newUser.EventDesc  = EditEventDesc;
            Events.Remove(SelectedEvent);
            Events.Add(newUser);
            ReloadList();
        }
        private void biEditEvent_ItemClick(object sender, ItemClickEventArgs e)
        {
            if (Ticker == null)
            {
                return;
            }
            TickerEvent   ev   = SelectedEvent.Clone();
            EventEditForm form = new EventEditForm();

            form.Event = ev;
            if (form.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            SelectedEvent.Assign(ev);
            Ticker.OnEventsChanged();
        }
Пример #4
0
        private async void SubmitCommandExecuted()
        {
            if (!IsEditMode)
            {
                if (AreEventsVisible)
                {
                    EventReminder.EventReminder.EventID = SelectedEvent.Event.ID;
                    EventReminder.EventReminder.Event   = SelectedEvent.Event;
                }
                else
                {
                    _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 = "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     = "Event-Reminder",
                    Message     = msg,
                });

                await EmailService.SendEmail(email, null, null);

                if (AreEventsVisible)
                {
                    _originalEvent = SelectedEvent.Clone();
                    SelectedEvent.EventReminders.Add(EventReminder);
                    var eventUpdates = LoggingService.FindDifference(_originalEvent, SelectedEvent);
                    if (!SelectedEvent.EventUpdates.Any())
                    {
                        var updates = await _eventDataUnit.EventUpdatesRepository.GetAllAsync(x => x.EventID == SelectedEvent.Event.ID);

                        SelectedEvent.EventUpdates = new ObservableCollection <EventUpdate>(updates.OrderByDescending(x => x.Date));
                    }
                    ProcessUpdates(SelectedEvent, eventUpdates);

                    await _eventDataUnit.SaveChanges();
                }
            }
            else
            {
                _eventReminder.AssignedToUser = AssignedToUser;
                _eventReminder.EventReminder.AssignedToUserID = AssignedToUser.ID;
                EventReminder.EventReminder.LastEditDate      = DateTime.Now;
                if (AreEventsVisible)
                {
                    if (_originalEvent.Event.ID != _selectedEvent.Event.ID)
                    {
                        _originalEvent = _selectedEvent.Clone();
                    }

                    EventReminder.EventReminder.Event = SelectedEvent.Event;
                    SelectedEvent.EventReminders.Where(x => x.EventReminder == _eventReminder.EventReminder).FirstOrDefault().AssignedToUser = AssignedToUser;
                    var eventUpdates = LoggingService.FindDifference(_originalEvent, SelectedEvent);
                    if (!SelectedEvent.EventUpdates.Any())
                    {
                        var updates = await _eventDataUnit.EventUpdatesRepository.GetAllAsync(x => x.EventID == SelectedEvent.Event.ID);

                        SelectedEvent.EventUpdates = new ObservableCollection <EventUpdate>(updates.OrderByDescending(x => x.Date));
                    }
                    ProcessUpdates(_selectedEvent, eventUpdates);

                    await _eventDataUnit.SaveChanges();
                }
                else
                {
                    _eventDataUnit.EventRemindersRepository.SetEntityModified(_eventReminder.EventReminder);
                }
                EventReminder.Refresh();
            }
        }