示例#1
0
        public Response GetAll()
        {
            var response    = new Response();
            var harwareList = new List <Hardware>();

            var config = LinksHelper.GetLinks("hardwareList");

            if (config == null)
            {
                response.Status = Status.Error;
                response.AddErrorNotification("Configuration of hardwareList missing");
                return(response);
            }

            foreach (LinkItem link in config)
            {
                var linkUrl      = $"{link.Url.EnsureSlash()}hardware/get";
                var responseItem = ApiClient.Get <Response>(linkUrl);
                if (responseItem.Status == Status.Success)
                {
                    var innerResponse = (Response)responseItem.Data;
                    response.Notifications.AddRange(innerResponse.Notifications);
                    if (innerResponse.Status == Status.Success)
                    {
                        var data = ((JObject)innerResponse.Data).ToObject <Hardware>();
                        harwareList.Add(data);
                    }
                }
                response.Notifications.AddRange(responseItem.Notifications);
            }

            response.Data = harwareList;
            return(response);
        }
示例#2
0
        // GET api/<controller>
        public Response Get()
        {
            var response = new Response();

            _linkCollection = LinksHelper.GetLinks("links");
            if (_linkCollection == null)
            {
                response.Status = Status.Error;
                response.AddErrorNotification("Configuration of links missing");
                return(response);
            }

            var links = CacheManager.GetObjectFromCache("Links", _cacheLifecycle, GetLinksStatus);

            response.Data = links;
            return(response);
        }