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