Exemplo n.º 1
0
        public IActionResult GetObjectTypes(string clientID)
        {
            IActionResult result;
            Guid          clientIDGuid;

            if (StringUtils.GuidTryDecode(clientID, out clientIDGuid))
            {
                Model.Client client = BusinessLogicFactory.Clients.GetClient(clientIDGuid);
                if (client != null)
                {
                    ServiceModels.ObjectTypes response = new ServiceModels.ObjectTypes();
                    string rootUrl = Request.GetRootUrl();

                    if (client.SupportedTypes != null)
                    {
                        Model.ObjectDefinitionLookups definitions = BusinessLogicFactory.ObjectDefinitions.GetLookups();

                        response.PageInfo = Request.GetPageInfo(client.SupportedTypes.Count);
                        int endIndex = response.PageInfo.StartIndex + response.PageInfo.ItemsCount;
                        for (int index = response.PageInfo.StartIndex; index < endIndex; index++)
                        {
                            ServiceModels.ObjectType objectType = new ServiceModels.ObjectType(client.SupportedTypes[index]);
                            if (definitions != null)
                            {
                                Model.ObjectDefinition definition = definitions.GetObjectDefinition(User.GetOrganisationID(), objectType.ObjectTypeID);
                                if (definition != null)
                                {
                                    objectType.AddSelfLink(string.Concat(rootUrl, "/clients/", clientID, "/objecttypes/", StringUtils.GuidEncode(definition.ObjectDefinitionID)), false, false);
                                    objectType.AddLink <ObjectDefinition>(Request, "definition", string.Concat(rootUrl, "/objecttypes/definitions/", StringUtils.GuidEncode(definition.ObjectDefinitionID)));
                                    objectType.AddLink("instances", string.Concat(rootUrl, "/clients/", clientID, "/objecttypes/", StringUtils.GuidEncode(definition.ObjectDefinitionID), "/instances"), Request.GetContentType(definition.MIMEType));
                                }
                            }
                            response.Add(objectType);
                        }
                    }
                    result = Request.GetObjectResult(response);
                }
                else
                {
                    result = new NotFoundResult();
                }
            }
            else
            {
                result = new BadRequestResult();
            }

            return(result);
        }
Exemplo n.º 2
0
        public IActionResult GetObjectTypes(string clientID)
        {
            IActionResult result;
            Guid clientIDGuid;
            if (StringUtils.GuidTryDecode(clientID, out clientIDGuid))
            {
                Model.Client client = BusinessLogicFactory.Clients.GetClient(clientIDGuid);
                if (client != null)
                {
                    ServiceModels.ObjectTypes response = new ServiceModels.ObjectTypes();
                    string rootUrl = Request.GetRootUrl();

                    if (client.SupportedTypes != null)
                    {
                        Model.ObjectDefinitionLookups definitions = BusinessLogicFactory.ObjectDefinitions.GetLookups();

                        response.PageInfo = Request.GetPageInfo(client.SupportedTypes.Count);
                        int endIndex = response.PageInfo.StartIndex + response.PageInfo.ItemsCount;
                        for (int index = response.PageInfo.StartIndex; index < endIndex; index++)
                        {
                            ServiceModels.ObjectType objectType = new ServiceModels.ObjectType(client.SupportedTypes[index]);
                            if (definitions != null)
                            {
                                Model.ObjectDefinition definition = definitions.GetObjectDefinition(User.GetOrganisationID(), objectType.ObjectTypeID);
                                if (definition != null)
                                {
                                    objectType.AddSelfLink(string.Concat(rootUrl, "/clients/", clientID, "/objecttypes/", StringUtils.GuidEncode(definition.ObjectDefinitionID)), false, false);
                                    objectType.AddLink<ObjectDefinition>(Request, "definition", string.Concat(rootUrl, "/objecttypes/definitions/", StringUtils.GuidEncode(definition.ObjectDefinitionID)));
                                    objectType.AddLink("instances", string.Concat(rootUrl, "/clients/", clientID, "/objecttypes/", StringUtils.GuidEncode(definition.ObjectDefinitionID), "/instances"), Request.GetContentType(definition.MIMEType));
                                }
                            }
                            response.Add(objectType);
                        }
                    }
                    result = Request.GetObjectResult(response);
                }
                else
                {
                    result = new NotFoundResult();
                }
            }
            else
            {
                result = new BadRequestResult();
            }

            return result;
        }