Ejemplo n.º 1
0
        public HttpResponseMessage GetByMasterNumber([FromUri] string id)
        {
            string authorizationString = DecodeAuthorizationString();

            SPHelper.SetSharePointCredentials(authorizationString);

            List <SharePointDocument> files = new List <SharePointDocument>();

            ListItemCollection list = SPHelper.GetDocumentsByNumber(id);

            if (list != null && list.AreItemsAvailable)
            {
                foreach (ListItem item in list)
                {
                    SharePointDocument file = ListItemToSharePointDocument(item);
                    files.Add(file);
                }
            }

            var response = Request.CreateResponse(HttpStatusCode.OK);

            response.Content = new StringContent(JsonConvert.SerializeObject(files), Encoding.UTF8, "application/json");
            return(response);
        }