using System;
using InABox.Core;

namespace InABox.Rpc
{
    public class RpcDeleteParameters : IRpcCommandParameters
    {
        /// <summary>
        /// The type to be deleted; guaranteed to be an <see cref="Entity"/>.
        /// </summary>
        public Type Type { get; set; }
        
        public Guid[] IDs { get; set; }

        public string AuditNote { get; set; }

        public string CommandName => "Delete";

        public void SerializeBinary(CoreBinaryWriter writer)
        {
            writer.Write(Type.EntityName());
            writer.WriteBinaryValue(IDs);
            writer.Write(AuditNote);
        }

        public void DeserializeBinary(CoreBinaryReader reader)
        {
            Type = CoreUtils.GetEntity(reader.ReadString());
            IDs = reader.ReadBinaryValue<Guid[]>();
            AuditNote = reader.ReadString();
        }

        public string FullDescription() => $"Delete{Type.Name}({IDs.Length}) IDs=[{string.Join(',', IDs)}]";

        public string ShortDescription() => $"Delete{Type.Name}({IDs.Length})";
    }
}