Exemplo n.º 1
0
        private ReleaseStatus GetReleaseStatus(ReleaseStatus request)
        {
            var           id    = request?.Id;
            ReleaseStatus ret   = null;
            var           query = DocQuery.ActiveQuery ?? Execute;

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

            DocEntityReleaseStatus entity = null;

            if (id.HasValue)
            {
                entity = DocEntityReleaseStatus.GetReleaseStatus(id.Value);
            }
            if (null == entity)
            {
                throw new HttpError(HttpStatusCode.NotFound, $"No ReleaseStatus 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);
        }
Exemplo n.º 2
0
        public ReleaseStatus Post(ReleaseStatusCopy request)
        {
            ReleaseStatus ret = null;

            using (Execute)
            {
                Execute.Run(ssn =>
                {
                    var entity = DocEntityReleaseStatus.GetReleaseStatus(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 pBranch = entity.Branch;
                    if (!DocTools.IsNullOrEmpty(pBranch))
                    {
                        pBranch += " (Copy)";
                    }
                    var pRelease = entity.Release;
                    if (!DocTools.IsNullOrEmpty(pRelease))
                    {
                        pRelease += " (Copy)";
                    }
                    var pServer = entity.Server;
                    if (!DocTools.IsNullOrEmpty(pServer))
                    {
                        pServer += " (Copy)";
                    }
                    var pURL = entity.URL;
                    if (!DocTools.IsNullOrEmpty(pURL))
                    {
                        pURL += " (Copy)";
                    }
                    var pVersion = entity.Version;
                    if (!DocTools.IsNullOrEmpty(pVersion))
                    {
                        pVersion += " (Copy)";
                    }
                    #region Custom Before copyReleaseStatus
                    #endregion Custom Before copyReleaseStatus
                    var copy = new DocEntityReleaseStatus(ssn)
                    {
                        Hash      = Guid.NewGuid()
                        , Branch  = pBranch
                        , Release = pRelease
                        , Server  = pServer
                        , URL     = pURL
                        , Version = pVersion
                    };

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