Пример #1
0
        public ActionResult <PartDefinition[]> GetFacetParts(string database,
                                                             [FromRoute] string id,
                                                             [FromQuery] bool noRoles = false)
        {
            ICadmusRepository repository =
                _repositoryProvider.CreateRepository(database);

            FacetDefinition facet = repository.GetFacetDefinition(id);

            PartDefinition[] result = CollectFacetParts(facet, noRoles);
            return(Ok(result));
        }
Пример #2
0
        public ActionResult <PartDefinition> GetFacet(
            string database,
            [FromRoute] string id)
        {
            ICadmusRepository repository =
                _repositoryProvider.CreateRepository(database);

            FacetDefinition facet = repository.GetFacetDefinition(id);

            if (facet == null)
            {
                return(NotFound());
            }
            return(Ok(facet));
        }
Пример #3
0
        public ActionResult <PartDefinition> GetFacetFromItemId(
            string database,
            [FromRoute] string id)
        {
            ICadmusRepository repository =
                _repositoryProvider.CreateRepository(database);

            IItem item = repository.GetItem(id, false);

            if (item?.FacetId == null)
            {
                return(NotFound());
            }

            FacetDefinition facet = repository.GetFacetDefinition(item.FacetId);

            if (facet == null)
            {
                return(NotFound());
            }
            return(Ok(facet));
        }
Пример #4
0
        public ActionResult <PartDefinition[]> GetFacetPartsFromItem(
            string database,
            [FromRoute] string id,
            [FromQuery] bool noRoles = false)
        {
            ICadmusRepository repository =
                _repositoryProvider.CreateRepository(database);

            IItem item = repository.GetItem(id, false);

            PartDefinition[] result;

            if (item?.FacetId != null)
            {
                FacetDefinition facet = repository.GetFacetDefinition(item.FacetId);
                result = CollectFacetParts(facet, noRoles);
            }
            else
            {
                result = Array.Empty <PartDefinition>();
            }

            return(Ok(result));
        }