private async void EditEventCommandExecuted(EventModel item) { // We should get event from EventDataUnit to use EventBookingView var events = await _eventsDataUnit.EventsRepository.GetLightEventsAsync(x => x.ID == item.Event.ID); var model = new EventModel(events.FirstOrDefault()); RaisePropertyChanged("DisableParentWindow"); var view = new BookingView(BookingViews.Event, model); view.ShowDialog(); RaisePropertyChanged("EnableParentWindow"); if (view.DialogResult != null && view.DialogResult.Value) { _contactsDataUnit.EventsRepository.Refresh(); events = await _contactsDataUnit.EventsRepository.GetLightEventsAsync(x => x.ID == model.Event.ID); Event = new EventModel(events.FirstOrDefault()); await LoadLightEventDetails(); model.RefreshItems(); } }
private void OpenEventCommandExecute() { RaisePropertyChanged("DisableParentWindow"); var window = new BookingView(BookingViews.Event, new EventModel(EventReminder.EventReminder.Event)); window.ShowDialog(); RaisePropertyChanged("EnableParentWindow"); }
private void OpenEventCommandExecuted() { RaisePropertyChanged("DisableParentWindow"); var window = new BookingView(BookingViews.Event, new EventModel(EventReminder.EventReminder.Event)); window.ShowDialog(); if (window.DialogResult != null && window.DialogResult.Value) { var IsCurrentEventReminderDeleted = true; var eventBookingView = window.ViewModel.Content as EventBookingView; var eventBookingViewModel = eventBookingView.ViewModel as EventBookingViewModel; if (eventBookingViewModel.Event.EventReminders.Where(eventReminder => eventReminder.EventReminder.ID == _eventReminder.EventReminder.ID).Count() > 0) { IsCurrentEventReminderDeleted = false; } if (IsCurrentEventReminderDeleted) { Application.Current.Dispatcher.BeginInvoke(new Action(() => { //var currentPopUp = Application.Current.MainWindow; //var viewModel = currentPopUp.DataContext as MainWindowModel; //var workspaceView = viewModel.WindowContent as WorkspaceView; //var tile = workspaceView.RootTileView.MaximizedItem as Tile; //if (tile.Name == "CRM") //{ // var crmview = tile.Content as CRMView; // var crmvm = crmview.DataContext as CRMViewModel; // if (isToDo) // crmvm.ReloadFollowUps(); // else // { // crmvm.ReloadFollowUpsAndEnquiries(); // } //} })); RaisePropertyChanged("CloseParentWindow"); } else { RaisePropertyChanged("EnableParentWindow"); } } else { RaisePropertyChanged("EnableParentWindow"); } }
private void EditEventCommandExecuted(EventModel item) { RaisePropertyChanged("DisableParentWindow"); var bookingView = new BookingView(EventManagementSystem.ViewModels.Core.Booking.BookingViews.Event, item); bookingView.ShowDialog(); RaisePropertyChanged("EnableParentWindow"); if (bookingView.DialogResult != null && bookingView.DialogResult == true) { item.Refresh(); item.RefreshItems(); } else { item.Refresh(); } }
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(); }