private Outcome GetOutcome(Outcome request)
        {
            var     id    = request?.Id;
            Outcome ret   = null;
            var     query = DocQuery.ActiveQuery ?? Execute;

            DocPermissionFactory.SetVisibleFields <Outcome>(currentUser, "Outcome", request.VisibleFields);

            DocEntityOutcome entity = null;

            if (id.HasValue)
            {
                entity = DocEntityOutcome.GetOutcome(id.Value);
            }
            if (null == entity)
            {
                throw new HttpError(HttpStatusCode.NotFound, $"No Outcome found for Id {id.Value}");
            }

            if (!DocPermissionFactory.HasPermission(entity, currentUser, DocConstantPermission.VIEW))
            {
                throw new HttpError(HttpStatusCode.Forbidden, "You do not have VIEW permission for this route.");
            }

            ret = entity?.ToDto();
            return(ret);
        }
        public Outcome Post(OutcomeCopy request)
        {
            Outcome ret = null;

            using (Execute)
            {
                Execute.Run(ssn =>
                {
                    var entity = DocEntityOutcome.GetOutcome(request?.Id);
                    if (null == entity)
                    {
                        throw new HttpError(HttpStatusCode.NoContent, "The COPY request did not succeed.");
                    }
                    if (!DocPermissionFactory.HasPermission(entity, currentUser, DocConstantPermission.ADD))
                    {
                        throw new HttpError(HttpStatusCode.Forbidden, "You do not have ADD permission for this route.");
                    }

                    var pDocumentSets = entity.DocumentSets.ToList();
                    var pName         = entity.Name;
                    if (!DocTools.IsNullOrEmpty(pName))
                    {
                        pName += " (Copy)";
                    }
                    var pURI = entity.URI;
                    if (!DocTools.IsNullOrEmpty(pURI))
                    {
                        pURI += " (Copy)";
                    }
                    #region Custom Before copyOutcome
                    #endregion Custom Before copyOutcome
                    var copy = new DocEntityOutcome(ssn)
                    {
                        Hash   = Guid.NewGuid()
                        , Name = pName
                        , URI  = pURI
                    };
                    foreach (var item in pDocumentSets)
                    {
                        entity.DocumentSets.Add(item);
                    }

                    #region Custom After copyOutcome
                    #endregion Custom After copyOutcome
                    copy.SaveChanges(DocConstantPermission.ADD);
                    ret = copy.ToDto();
                });
            }
            return(ret);
        }