Beispiel #1
0
        private void AddEnquiryStatusCommandExecute()
        {
            var newEnquiryStatus = GetNewEnquiryStatus();

            _adminDataUnit.EnquiryStatusesRepository.Add(newEnquiryStatus);
            _adminDataUnit.SaveChanges();
            EnquiryStatuses.Add(newEnquiryStatus);
        }
Beispiel #2
0
        private void DeleteEnquiryStatusCommandExecute()
        {
            var dp = new DialogParameters {
                Content = "Are you sure you want to delete " + ((EnquiryStatus)SelectedObject).Status + "?"
            };

            dp.Content            += "\n";
            dp.Header              = "Warning!";
            dp.OkButtonContent     = "Yes";
            dp.CancelButtonContent = "No";
            dp.Closed              = ConfirmDeleteClose;
            dp.Owner = Application.Current.MainWindow;

            RadWindow.Confirm(dp);
            if (_yesNo)
            {
                _adminDataUnit.EnquiryStatusesRepository.Delete((EnquiryStatus)SelectedObject);
                _adminDataUnit.SaveChanges();
                EnquiryStatuses.Remove((EnquiryStatus)SelectedObject);
                _yesNo = false;
            }

            SelectedObject = null;
        }
Beispiel #3
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();
        }