示例#1
0
        virtual public void UpdateEventTypesAndTimers()
        {
            IEnumerable <EventType> dashboardtypes = new List <EventType> ();
            IEnumerable <EventType> timelinetypes;

            if (Dashboard != null)
            {
                /* Timers */
                IEnumerable <Timer> timers = Dashboard.List.OfType <TimerButton> ().Select(b => b.Timer).OfType <Timer> ();
                Timers.AddRange(timers.Except(Timers));

                /* Update event types list that changes when the user adds or remove a
                 * a new button to the dashboard or after importing a project with events
                 * tagged with a different dashboard */
                dashboardtypes = Dashboard.List.OfType <EventButton> ().Select(b => b.EventType);
            }

            /* Remove event types that have no events and are not in the dashboard anymore */
            foreach (EventType evt in EventTypes.Except(dashboardtypes).ToList())
            {
                if (Timeline.Count(e => e.EventType == evt) == 0)
                {
                    EventTypes.Remove(evt);
                }
            }
            EventTypes.AddRange(dashboardtypes.Except(EventTypes));
            timelinetypes = Timeline.Select(t => t.EventType).Distinct().Except(EventTypes);
            EventTypes.AddRange(timelinetypes.Except(EventTypes));

            /* Remove null EventTypes just in case */
            EventTypes = new RangeObservableCollection <EventType> (EventTypes.Where(e => e != null));
        }
示例#2
0
        public bool DeleteEventType(int id, out string response)
        {
            EventType toRemove = EventTypes.GetEventTypeWithEvents(id);

            if (toRemove == null)
            {
                response = $"Cannot delete Event Type: No Event Type with id {id} was found.";
                return(false);
            }
            else if (toRemove.Events.Count() > 0)
            {
                response = $"Cannot delete Event Type: Event Type has Events assigned.";
                return(false);
            }
            try
            {
                EventTypes.Remove(toRemove);
                Complete();
                response = "Event Type deleted.";
                return(true);
            }
            catch (Exception ex)
            {
                response = ex.Message;
                return(false);
            }
        }
示例#3
0
        private void DeleteEventPropertyCommandExecuted()
        {
            if (SelectedObject == null)
            {
                return;
            }

            bool?dialogResult = null;

            /*string confirmText = Properties.Resources.MESSAGE_ASK_BEFORE_DELETING_ITEM + Environment.NewLine
             + "Another elements of the system may depend on this item. " + Environment.NewLine
             +"The system automatically deletes all data that depend on this item. Are you sure?";*/

            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;
            }

            if (SelectedObject is EventTypeModel)
            {
                // check if any product depend on this event type
                if (SelectedEventType.EventType.ProductEventTypes.Any())
                {
                    // remove all ProductEventTypes that depend on this EventType
                    _adminDataUnit.ProductEventTypesRepository.Delete(SelectedEventType.EventType.ProductEventTypes.ToList());
                }

                // delete event type options
                _adminDataUnit.EventTypeOptionsRepository.Delete(SelectedEventType.EventType.EventTypeOptions.ToList());

                // delete event type
                _adminDataUnit.EventTypesRepository.Delete(SelectedEventType.EventType);
                _adminDataUnit.SaveChanges();

                EventTypes.Remove(SelectedEventType);
                SelectedEventType = null;
            }
            else if (SelectedObject is EventStatusModel)
            {
                // delete event status options
                _adminDataUnit.EventStatusOptionsRepository.Delete(SelectedEventStatus.EventStatus.EventStatusOptions.ToList());

                // delete event status
                _adminDataUnit.EventStatusesRepository.Delete(SelectedEventStatus.EventStatus);
                _adminDataUnit.SaveChanges();

                EventStatuses.Remove(SelectedEventStatus);
                SelectedEventStatus = null;
            }
            else if (SelectedObject is FollowUpStatus)
            {
                _adminDataUnit.FollowUpStatusesRepository.Delete(SelectedTODOStatus);
                _adminDataUnit.SaveChanges();
                TODOStatuses.Remove(SelectedTODOStatus);
                SelectedTODOStatus = null;
            }
        }