using BO.AppServer.Metadata.Dto;
using BO.Console.Commands.Base;
using Quadarax.Foundation.Core.QConsole;
using Quadarax.Foundation.Core.QConsole.Attributes;

namespace BO.Console.Commands.Catalogues
{
    [CommandDefinition]
    internal class MimeTypeAddCommand : AbstractPostCommand<MimeTypeCDto, MimeTypeRDto>
    {
        #region *** Constants ***
        private const string CS_CMD_MIMEADD_NAME = "mime_add";
        private const string CS_CMD_MIMEADD_DESCR = "Add new mime type/s by import file.";
        #endregion

        #region *** Properties ***

        public override string Name => CS_CMD_MIMEADD_NAME;
        public override string Description => CS_CMD_MIMEADD_DESCR;

        #endregion

        #region *** Constructor ***
        public MimeTypeAddCommand(Engine engine) : base(engine)
        {
        }
        #endregion

        #region *** EXECUTE ***
        protected override MimeTypeRDto IterationExecute(MimeTypeCDto data)
        {
            WriteDebugInfo($"MimeType '{data.Mimetype1}' starts creating...");
            var result = Client.CreateMimeTypeAsync(data).Result;
            WriteCaption($"MimeType '{data.Mimetype1}' created.");
            return result;
        }

        #endregion

        #region *** Private operations ***
        #endregion

    }
}
