Example #1
0
        private async void AddTODOStatusCommandExecuted()
        {
            var status = new FollowUpStatus
            {
                Color        = "#808080",
                ID           = Guid.NewGuid(),
                NumberOfDays = 0,
                Priority     = 1,
                Status       = "New TODO Status",
                StatusType   = Convert.ToInt32(StatusType.ToDosStatus)
            };

            _adminDataUnit.FollowUpStatusesRepository.Add(status);
            await _adminDataUnit.SaveChanges();

            TODOStatuses.Add(status);
            SelectedObject             = status;
            IsToDoStatusesTreeExpanded = true;
        }
Example #2
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;
            }
        }