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.Workspace
{
    [CommandDefinition]
    internal class WorkspaceAddCommand : AbstractPostCommand<WorkspaceCDto, WorkspaceRDto>
    {
        #region *** Constants ***
        private const string CS_CMD_WKSPADD_NAME = "workspace_add";
        private const string CS_CMD_WKSPADD_DESCR = "Add new workspace/s assigned to user by import file.";

        #endregion

        #region *** Properties ***

        public override string Name => CS_CMD_WKSPADD_NAME;
        public override string Description => CS_CMD_WKSPADD_DESCR;

        #endregion

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

        #region *** EXECUTE ***
        protected override  WorkspaceRDto IterationExecute(WorkspaceCDto data)
        {
            WriteDebugInfo($"Workspace '{data.Name}' for user '{data.AssignedUserName}' starts creating...");
            var result = Client.CreateWorkspaceAsync(data).Result;
            WriteCaption($"Workspace '{data.Name}' for user '{data.AssignedUserName}' created.");
            return result;
        }

        #endregion

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