コード例 #1
0
        public void Delete(ServePortalSet request)
        {
            using (Execute)
            {
                Execute.Run(ssn =>
                {
                    if (!(request?.Id > 0))
                    {
                        throw new HttpError(HttpStatusCode.NotFound, $"No Id provided for delete.");
                    }

                    var en = DocEntityServePortalSet.Get(request?.Id);
                    if (null == en)
                    {
                        throw new HttpError(HttpStatusCode.NotFound, $"No ServePortalSet could be found for Id {request?.Id}.");
                    }
                    if (en.IsRemoved)
                    {
                        return;
                    }

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

                    en.Remove();

                    DocCacheClient.RemoveSearch(DocConstantModelName.SERVEPORTALSET);
                    DocCacheClient.RemoveById(request.Id);
                });
            }
        }
コード例 #2
0
        private ServePortalSet GetServePortalSet(ServePortalSet request)
        {
            var            id    = request?.Id;
            ServePortalSet ret   = null;
            var            query = DocQuery.ActiveQuery ?? Execute;

            DocPermissionFactory.SetSelect <ServePortalSet>(currentUser, "ServePortalSet", request.Select);

            DocEntityServePortalSet entity = null;

            if (id.HasValue)
            {
                entity = DocEntityServePortalSet.Get(id.Value);
            }
            if (null == entity)
            {
                throw new HttpError(HttpStatusCode.NotFound, $"No ServePortalSet 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);
        }
コード例 #3
0
        public ServePortalSet Post(ServePortalSetCopy request)
        {
            ServePortalSet ret = null;

            using (Execute)
            {
                Execute.Run(ssn =>
                {
                    var entity = DocEntityServePortalSet.Get(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 pClients             = entity.Clients.ToList();
                    var pConfidential        = entity.Confidential;
                    var pDivisions           = entity.Divisions.ToList();
                    var pDocuments           = entity.Documents.ToList();
                    var pDocumentSets        = entity.DocumentSets.ToList();
                    var pDrugClasses         = entity.DrugClasses.ToList();
                    var pHistories           = entity.Histories.ToList();
                    var pInterventions       = entity.Interventions.ToList();
                    var pLegacyDocumentSetId = entity.LegacyDocumentSetId;
                    var pName = entity.Name;
                    if (!DocTools.IsNullOrEmpty(pName))
                    {
                        pName += " (Copy)";
                    }
                    var pOwner       = entity.Owner;
                    var pProjectTeam = entity.ProjectTeam;
                    var pScopes      = entity.Scopes.ToList();
                    var pSettings    = entity.Settings;
                    var pStats       = entity.Stats.ToList();
                    var pType        = entity.Type;
                    var pUsers       = entity.Users.ToList();
                    var copy         = new DocEntityServePortalSet(ssn)
                    {
                        Hash                  = Guid.NewGuid()
                        , Confidential        = pConfidential
                        , LegacyDocumentSetId = pLegacyDocumentSetId
                        , Name                = pName
                        , Owner               = pOwner
                        , ProjectTeam         = pProjectTeam
                        , Settings            = pSettings
                        , Type                = pType
                    };
                    foreach (var item in pClients)
                    {
                        entity.Clients.Add(item);
                    }

                    foreach (var item in pDivisions)
                    {
                        entity.Divisions.Add(item);
                    }

                    foreach (var item in pDocuments)
                    {
                        entity.Documents.Add(item);
                    }

                    foreach (var item in pDocumentSets)
                    {
                        entity.DocumentSets.Add(item);
                    }

                    foreach (var item in pDrugClasses)
                    {
                        entity.DrugClasses.Add(item);
                    }

                    foreach (var item in pHistories)
                    {
                        entity.Histories.Add(item);
                    }

                    foreach (var item in pInterventions)
                    {
                        entity.Interventions.Add(item);
                    }

                    foreach (var item in pScopes)
                    {
                        entity.Scopes.Add(item);
                    }

                    foreach (var item in pStats)
                    {
                        entity.Stats.Add(item);
                    }

                    foreach (var item in pUsers)
                    {
                        entity.Users.Add(item);
                    }

                    copy.SaveChanges(DocConstantPermission.ADD);
                    ret = copy.ToDto();
                });
            }
            return(ret);
        }