Пример #1
0
        private void ProcessNote(EventNoteModel noteModel)
        {
            _isEditMode = (noteModel != null);

            EventNote = (_isEditMode) ? noteModel : GetNote();
            EventNote.PropertyChanged += EventNoteOnPropertyChanged;
        }
Пример #2
0
        public AddNoteView(EventModel eventModel, EventNoteModel note = null)
        {
            InitializeComponent();
            DataContext = ViewModel = new AddNoteViewModel(eventModel, note);

            Owner = Application.Current.MainWindow;

            Loaded += OnAddNoteViewLoaded;
        }
Пример #3
0
        private EventNoteModel GetNote()
        {
            var noteModel = new EventNoteModel(new EventNote()
            {
                ID      = Guid.NewGuid(),
                EventID = _event.Event.ID,
                Date    = DateTime.Now,
                UserID  = AccessService.Current.User.ID
            });

            return(noteModel);
        }
Пример #4
0
        public AddNoteViewModel(EventModel eventModel, EventNoteModel noteModel)
        {
            _event = eventModel;

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

            _eventsDataUnit = dataUnitLocator.ResolveDataUnit <IEventDataUnit>();

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

            ProcessNote(noteModel);
        }
Пример #5
0
        private void EditNoteCommandExecuted(EventNoteModel item)
        {
            RaisePropertyChanged("DisableParentWindow");

            var window = new AddNoteView(Event, item);

            window.ShowDialog();

            if (window.DialogResult != null && window.DialogResult.Value)
            {
                _event.Event.LastEditDate = DateTime.Now;
            }

            RaisePropertyChanged("EnableParentWindow");
        }
Пример #6
0
 private void DeleteNoteCommandExecuted(EventNoteModel item)
 {
     _event.EventNotes.Remove(item);
     _eventsDataUnit.EventNotesRepository.Delete(item.EventNote);
     _event.Event.LastEditDate = DateTime.Now;
 }
Пример #7
0
        private async void BookCommandExecute()
        {
            bool?  dialogResult = null;
            string confirmText  = Properties.Resources.MESSAGE_ASK_BEFORE_BOOKING_ENQUIRY;

            RadWindow.Confirm(new DialogParameters()
            {
                Owner   = Application.Current.MainWindow,
                Content = confirmText,
                Closed  = (sender, args) => { dialogResult = args.DialogResult; }
            });

            if (dialogResult != true)
            {
                return;
            }

            Enquiry.EnquiryStatus = EnquiryStatuses.FirstOrDefault(x => x.Status == "Booked");
            EnquiryStatus         = Enquiry.EnquiryStatus;

            var newEvent = new Event()
            {
                ID             = Guid.NewGuid(),
                Name           = Enquiry.Name,
                Date           = (DateTime)Enquiry.Date,
                Places         = (int)Enquiry.Places,
                CreationDate   = DateTime.Now,
                ShowOnCalendar = true,
                IsDeleted      = false,
                LastEditDate   = DateTime.Now,
                EventTypeID    = Enquiry.EventType.ID,
                EnquiryID      = Enquiry.Enquiry.ID,
                EventStatusID  = _eventStatuses.FirstOrDefault(x => x.Name == "Provisional").ID
            };

            if (_enquiry.PrimaryContact != null)
            {
                newEvent.ContactID = _enquiry.PrimaryContact.Contact.ID;
            }

            _crmDataUnit.EventsRepository.Add(newEvent);

            var update = new EventUpdate()
            {
                ID       = Guid.NewGuid(),
                EventID  = newEvent.ID,
                Date     = DateTime.Now,
                UserID   = AccessService.Current.User.ID,
                Message  = string.Format("Event {0} was created", newEvent.Name),
                OldValue = null,
                NewValue = newEvent.Name,
                ItemId   = newEvent.ID,
                ItemType = "Event",
                Field    = "Event",
                Action   = UpdateAction.Added
            };

            _crmDataUnit.EventUpdatesRepository.Add(update);
            _crmDataUnit.SaveChanges();

            // Warning: Here we use EventDataUnit!

            var events = await _eventDataUnit.EventsRepository.GetLightEventsAsync(x => x.ID == newEvent.ID);

            var @event = events.FirstOrDefault();

            var item = new EventModel(@event);

            // Open Add Event window in UI thread
            Application.Current.Dispatcher.BeginInvoke(new Action(() =>
            {
                var bookingView = new BookingView(BookingViews.Event, item);
                bookingView.ShowDialog();

                if (bookingView.DialogResult != null && bookingView.DialogResult == true)
                {
                    string campaingText = Enquiry.Campaign == null ? "" : ", via Campaign " + Enquiry.Campaign.Name;

                    var note = new EventNoteModel(new EventNote()
                    {
                        ID            = Guid.NewGuid(),
                        EventID       = newEvent.ID,
                        Date          = DateTime.Now,
                        EventNoteType = _eventNoteTypes.FirstOrDefault(x => x.Type == "Internal"),
                        UserID        = AccessService.Current.User.ID,
                        Note          = String.Format("From Enquiry, made on {0}, Taken by {1} Assigned to {2} enquiry via {3} {4}. {5} Notes, {6} Updates, {7} Activities & {8} Follow-Ups.",
                                                      DateTime.Now,
                                                      Enquiry.LoggedUser.FirstName,
                                                      Enquiry.AssignedToUser.FirstName,
                                                      Enquiry.ReceivedMethod.ReceiveMethod,
                                                      campaingText,
                                                      Enquiry.EnquiryNotes.Count,
                                                      Enquiry.EnquiryUpdates.Count,
                                                      Enquiry.Activities.Count,
                                                      Enquiry.FollowUps.Count)
                    });

                    _crmDataUnit.EventNotesRepository.Add(note.EventNote);
                    _crmDataUnit.SaveChanges();
                }
            }));

            BookCommand.RaiseCanExecuteChanged();
        }