public InternalMessage Draft(string Recipient, string Origin = null, int ParentId = 0)
        {
            InternalMessage model = new InternalMessage
            {
                Parent = new InternalMessage
                {
                    _Id = ParentId
                }
            };

            if (string.IsNullOrWhiteSpace(Origin))
            {
                model.From   = this.UserSession.LoggedInUser.ExternalId;
                model.Origin = this.UserSession.LoggedInUser.Guid;
            }
            else
            {
                SecurityGroup origin = this.SecurityGroupRepository.Find(Guid.Parse(Origin));

                model.From   = origin.ToString();
                model.Origin = origin.Guid;
            }

            SecurityGroup recipient = this.SecurityGroupRepository.Find(Guid.Parse(Recipient));

            model.Recipient = recipient?.Guid ?? Guid.Parse(Recipient);
            model.To        = recipient?.ToString() ?? Recipient;

            return(model);
        }
        public InternalMessage SendMessage(string Body, string Subject, Guid Recipient, int ParentId = 0, Guid?Origin = null)
        {
            if ((Origin.HasValue ? this.SecurityGroupRepository.Find(Origin.Value) as ISecurityGroup : this.UserSession.LoggedInUser) is ISecurityGroup origin)
            {
                SecurityGroup target = this.SecurityGroupRepository.Find(Recipient);

                InternalMessage toSend = new InternalMessage()
                {
                    Body      = Body,
                    Subject   = Subject,
                    Recipient = target?.Guid ?? Recipient,
                    Parent    = ParentId == 0 ? null : this.Find(ParentId),
                    Origin    = origin.Guid,
                    To        = target?.ToString() ?? Recipient.ToString(),
                    From      = origin.ToString()
                };

                return(this.SendMessage(toSend, target is User t ? t.Email : string.Empty));
            }
            else
            {
                throw new Exception("Unable to find security group for message.");
            }
        }