using System;
using System.Threading.Tasks;
using System.Windows;
using C4IT.FASD.Base;
using static C4IT.Logging.cLogManager;

namespace FasdDesktopUi.Basics.UiActions
{
    public sealed class cUiProcessTicketOverviewRelationAction : cUiActionBase
    {
        private readonly Func<Task> _runAsync;

        public cUiProcessTicketOverviewRelationAction(string name, Func<Task> runAsync)
        {
            Name = name;
            _runAsync = runAsync;
        }

        public override async Task<bool> RunUiActionAsync(object sender, UIElement UiLocation, bool isDetailedLayout, cSupportCaseDataProvider dataProvider)
        {
            try
            {
                if (_runAsync != null)
                    await _runAsync();
            }
            catch (Exception ex)
            {
                LogException(ex);
            }

            return false;
        }
    }
}
