SigTrade.Models.DocumentsRepository.getDocumentByID C# (CSharp) Method

getDocumentByID() public method

public getDocumentByID ( int ID ) : Document
ID int
return Document
        public Document getDocumentByID(int ID)
        {
            return DB.Get<Document>(ID);
        }

Usage Example

        // GET: /ProcessReview/GetDocument
        public ActionResult GetDocument(int docId)
        {
            try
            {
                string filename = null;
                IDocumentsRepository rep = new DocumentsRepository();
                var document = rep.getDocumentByID(docId);
                if (document == null)
                {
                    return null;
                }

                filename = document.DocPath + "\\" + document.DocName;

                string contentType = "";
                if (filename.IndexOf(".pdf") > -1)
                    contentType = "application/pdf";
                else if (filename.IndexOf(".doc") > -1)
                    contentType = "application/msword";
                else if (filename.IndexOf(".com") > -1)
                    contentType = "text/html";
                else if (filename.IndexOf(".txt") > -1)
                    contentType = "text/plain";
                if (!contentType.Equals(""))
                    return new FilePathResult(filename, contentType);
                else
                    return null;
            }
            catch (Exception e)
            {
                return null;
            }
            return null;
        }