예제 #1
0
        /// <summary>
        /// Удалить действие
        /// </summary>
        /// <param name="action"></param>
        public void Remove(Guid actionId)
        {
            var existingAction = _actions.FirstOrDefault(a => a.Id == actionId);

            if (existingAction != null)
            {
                _actions.Remove(existingAction);

                Write(_listFilePath, _actions);
                ActionsListUpdated?.Invoke(this, EventArgs.Empty);
            }
        }
예제 #2
0
        /// <summary>
        /// Добавить действие
        /// </summary>
        /// <param name="action"></param>
        public bool Add(Action action)
        {
            bool success = false;

            if (action != null)
            {
                var existingAction = _actions.FirstOrDefault(a => a.Id == action.Id);
                if (existingAction == null)
                {
                    _actions.Add(action.Clone());

                    Write(_listFilePath, _actions);
                    success = true;
                    ActionsListUpdated?.Invoke(this, EventArgs.Empty);
                }
            }

            return(success);
        }
예제 #3
0
        /// <summary>
        /// Обновить действие
        /// </summary>
        /// <param name="action"></param>
        public bool Update(Action action)
        {
            bool success = false;

            if (action != null)
            {
                var existingAction = _actions.FirstOrDefault(a => a.Id == action.Id);
                if (existingAction != null)
                {
                    var index = _actions.IndexOf(existingAction);
                    _actions.RemoveAt(index);
                    _actions.Insert(index, action.Clone());

                    Write(_listFilePath, _actions);
                    success = true;
                    ActionsListUpdated?.Invoke(this, EventArgs.Empty);
                }
            }

            return(success);
        }