﻿// MIT License. Copyright (c) 2016 Maxim Kuzmin. Contacts: https://github.com/maxim-kuzmin

// Author: Maxim Kuzmin

using Makc2017.Core.Execution.Operations.Async;
using Makc2017.Core.Resources.Errors;
using Makc2017.Modules.DummyTree.Filters;
using Makc2017.Modules.DummyTree.Resources.Successes;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace Makc2017.Modules.DummyTree.Operations.Item
{
    /// <summary>
    /// Модули. Модуль "DummyTree". Операции. Операция, выполняющая функцию  удаления элемента.
    /// </summary>
    public class ModuleDummyTreeOperationItemDelete : CoreExecutionOperationAsyncWithInputData
        <
            ModuleDummyTreeFilterItem
        >
    {
        #region Constructors

        /// <summary>
        /// Конструктор.
        /// </summary>
        /// <param name="executableFunction">Выполняемая функция.</param>
        /// <param name="coreResourceErrors">Ресурсы ошибок ядра.</param>
        /// <param name="moduleDummyTreeResourceSuccesses">Ресурсы успехов модуля.</param>
        public ModuleDummyTreeOperationItemDelete(
            Func<ModuleDummyTreeFilterItem, Task> executableFunction,
            CoreResourceErrors coreResourceErrors,
            ModuleDummyTreeResourceSuccesses moduleDummyTreeResourceSuccesses
            ) : base(
                executableFunction,
                null,
                null,
                inputData => GetSuccessMessages(inputData, moduleDummyTreeResourceSuccesses),
                null,
                coreResourceErrors
                )
        {
        }

        #endregion Constructors

        #region Private methods

        private static IEnumerable<string> GetSuccessMessages(
            ModuleDummyTreeFilterItem inputData,
            ModuleDummyTreeResourceSuccesses moduleDummyTreeResourceSuccesses
            )
        {
            return new[]
            {
                string.Format(
                    moduleDummyTreeResourceSuccesses.GetStringFormatObjectWithIdIsDeleted(),
                    inputData.Id
                    )
            };
        }

        #endregion Private methods
    }
}