Solvberget.Domain.Implementation.AlephRepository.GetDocument C# (CSharp) Method

GetDocument() public method

public GetDocument ( string documentNumber, bool isLight ) : Document
documentNumber string
isLight bool
return Solvberget.Domain.DTO.Document
        public Document GetDocument(string documentNumber, bool isLight)
        {
            const Operation function = Operation.FindDocument;
            var options = new Dictionary<string, string> { { "doc_number", documentNumber } };

            var url = GetUrl(function, options);

            var doc = RepositoryUtils.GetXmlFromStream(url);

            if (doc != null && doc.Root != null)
            {
                var xmlResult = doc.Root.Elements("record").Select(x => x).FirstOrDefault();
                if (xmlResult != null)
                {

                    //Add Aleph document information
                    var docToReturn = PopulateDocument(xmlResult, isLight);

                    //We add the docnumber here because it is not in the result
                    //when getting the document it self from Aleph
                    docToReturn.DocumentNumber = documentNumber;

                    //Add Alpeh location and availability information if not light
                    if (!isLight)
                        GenerateDocumentLocationAndAvailabilityInfo(docToReturn);

                    //Try to get ThumbnailUrl, and also ImageUrl if not light.
                    docToReturn.ThumbnailUrl = _storageHelper.GetLocalImageFileCacheUrl(docToReturn.DocumentNumber, true);
                    if (!isLight)
                        docToReturn.ImageUrl = _storageHelper.GetLocalImageFileCacheUrl(docToReturn.DocumentNumber, false);

                    return docToReturn;

                }
            }

            return null;
        }