示例#1
0
        public IActionResult GetObjectType(string clientID, string definitionID)
        {
            IActionResult result = new NotFoundResult();
            Guid          clientIDGuid;
            Guid          definitionIDGuid;

            if (StringUtils.GuidTryDecode(clientID, out clientIDGuid) && StringUtils.GuidTryDecode(definitionID, out definitionIDGuid))
            {
                Model.Client client = BusinessLogicFactory.Clients.GetClient(clientIDGuid);
                if ((client != null) && (client.SupportedTypes != null))
                {
                    Model.ObjectDefinition definition = BusinessLogicFactory.ObjectDefinitions.GetObjectDefinition(User.GetOrganisationID(), definitionIDGuid);
                    if (definition != null)
                    {
                        Model.ObjectType objectType = client.SupportedTypes.GetObjectType(int.Parse(definition.ObjectID));
                        if (objectType != null)
                        {
                            ServiceModels.ObjectType response = new ServiceModels.ObjectType(objectType);
                            string rootUrl = Request.GetRootUrl();
                            response.AddSelfLink(string.Concat(rootUrl, "/clients/", clientID, "/objecttypes/", definitionID), false, false);
                            response.AddLink <ObjectDefinition>(Request, "definition", string.Concat(rootUrl, "/objecttypes/definitions/", definitionID));
                            response.AddLink("instances", string.Concat(rootUrl, "/clients/", clientID, "/objecttypes/", definitionID, "/instances"), Request.GetContentType(definition.MIMEType));
                            result = Request.GetObjectResult(response);
                        }
                    }
                }
            }
            else
            {
                result = new BadRequestResult();
            }
            return(result);
        }
示例#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);
        }
        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;
        }
 public IActionResult GetObjectType(string clientID, string definitionID)
 {
     IActionResult result = new NotFoundResult();
     Guid clientIDGuid;
     Guid definitionIDGuid;
     if (StringUtils.GuidTryDecode(clientID, out clientIDGuid) && StringUtils.GuidTryDecode(definitionID, out definitionIDGuid))
     {
         Model.Client client = BusinessLogicFactory.Clients.GetClient(clientIDGuid);
         if ((client != null) && (client.SupportedTypes != null))
         {
             Model.ObjectDefinition definition = BusinessLogicFactory.ObjectDefinitions.GetObjectDefinition(User.GetOrganisationID(), definitionIDGuid);
             if (definition != null)
             {
                 Model.ObjectType objectType = client.SupportedTypes.GetObjectType(int.Parse(definition.ObjectID));
                 if (objectType != null)
                 {
                     ServiceModels.ObjectType response = new ServiceModels.ObjectType(objectType);
                     string rootUrl = Request.GetRootUrl();
                     response.AddSelfLink(string.Concat(rootUrl, "/clients/", clientID, "/objecttypes/", definitionID), false, false);
                     response.AddLink<ObjectDefinition>(Request, "definition", string.Concat(rootUrl, "/objecttypes/definitions/", definitionID));
                     response.AddLink("instances", string.Concat(rootUrl, "/clients/", clientID, "/objecttypes/", definitionID, "/instances"), Request.GetContentType(definition.MIMEType));
                     result = Request.GetObjectResult(response);
                 }
             }
         }
     }
     else
     {
         result = new BadRequestResult();
     }
     return result;
 }