//// GET: api/RemovePage/5
        public HttpResponseMessage Get(string id)
        {

            Logging.LogErrors(ConfigurationValues.ErrorLogPath, "start page removal");

            HttpResponseMessage result = new HttpResponseMessage(HttpStatusCode.OK);
            id = id + ",";
            PDFNet.Initialize(ConfigurationValues.PdfTronLicenseKey);

            string[] pagesToDelete = id.Split(',');
            DocumentRepository documentData = new DocumentRepository();
            int pageCount = 0;
            CurrentDocuments currentDocuments = documentData.GetCurrentDocumentPathPdf(Utility.GetUserName());
            string pathToCurrentPdfFile = currentDocuments.PathToCurrentPdfDocument;
            string pathToCurrentPdfFileTemp = pathToCurrentPdfFile.Replace(".pdf", "temp.pdf");
            string pathToCurrentXodFile = documentData.GetCurrentDocumentPathXod(Utility.GetUserName());

            PDFDoc removePagesFromDocument = new PDFDoc(pathToCurrentPdfFile);

            pageCount = removePagesFromDocument.GetPageCount();
            if (pageCount > 1)
            {
                try
                {
                    Logging.LogErrors(ConfigurationValues.ErrorLogPath, "begin remove page");
                    PageIterator itr = removePagesFromDocument.GetPageIterator(int.Parse(pagesToDelete[0]));
                    removePagesFromDocument.PageRemove(itr);
                    Logging.LogErrors(ConfigurationValues.ErrorLogPath, "end remove page");
                }
                catch (Exception er)
                {
                    Logging.LogErrors(ConfigurationValues.ErrorLogPath, er.ToString());
                }

                File.Create(pathToCurrentXodFile).Dispose();
                removePagesFromDocument.Save(pathToCurrentPdfFileTemp, 0);
                File.Delete(pathToCurrentXodFile);
                pdftron.Filters.Filter objFilter = pdftron.PDF.Convert.ToXod(pathToCurrentPdfFileTemp);
                System.Threading.Thread.Sleep(ConfigurationValues.XodSaveDelay);
                objFilter.WriteToFile(pathToCurrentXodFile,true );
                documentData.AddUpdateCurrentDocument(Utility.GetUserName(), pathToCurrentXodFile, pathToCurrentPdfFileTemp,
                    currentDocuments.CurrentDocumentList, documentData.GetFullPathToDocument(Utility.GetUserName()));
                Logging.LogErrors(ConfigurationValues.ErrorLogPath, "open stream");
                var stream = new FileStream(pathToCurrentXodFile, FileMode.Open);
                result.Content = new StreamContent(stream);
                result.Content.Headers.ContentType =
                    new MediaTypeHeaderValue("application/octet-stream");
                Logging.LogErrors(ConfigurationValues.ErrorLogPath, ConfigurationValues.XodFileName);
                result.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment")
                {
                    FileName = ConfigurationValues.XodFileName
                };
            }
            Logging.LogErrors(ConfigurationValues.ErrorLogPath, "done");

            return result;
        }
        //// GET: api/CurrentDocument
        //public IEnumerable<string> Get()
        //{
        //    return new string[] { "value1", "value2" };
        //}

        // GET: api/CurrentDocument
        public string Get()
        {
            DocumentRepository documentRepository = new DocumentRepository();
            CurrentDocuments currentDocument  = new CurrentDocuments();
            currentDocument = documentRepository.GetCurrentDocumentPathPdf(Utility.GetUserName());
            string[] filePath = currentDocument.PathToCurrentPdfDocument.Split('\\');
            //string dd = ConfigurationValues.AddressToXodFile + filePath[filePath.Length - 1];
            //return ConfigurationValues.AddressToXodFile + filePath[filePath.Length - 1];
            return ConfigurationValues.AddressToXodFile + filePath[filePath.Length - 1];
        }
 // POST: api/CustomSignature
 public IHttpActionResult Post([FromBody]Annotations customAnnotation)
 {
     try
     {
         customAnnotation.NewAnnotation = customAnnotation.NewAnnotation.Replace("~", "");
         customAnnotation.NewAnnotation = customAnnotation.NewAnnotation.Replace("\"", "'");
         DocumentRepository documentData = new DocumentRepository();
         documentData.AddCustomAnnotation(customAnnotation);
         return Ok();
     }
     catch
     {
         return BadRequest();
     }
 }
        // GET: api/DeleteDocument
        public IHttpActionResult Get()
        {
            DocumentRepository documentData = new DocumentRepository();
            ArchiveDocument archiveDocument = new ArchiveDocument();
            FolderRepository folderRepository = new FolderRepository();
            CurrentDocuments documentsToDelete = documentData.GetCurrentDocumentPathPdf(Utility.GetUserName());

            string[] faxesToDelete = documentsToDelete.CurrentDocumentList.Split('~');

            for (int i = 0; i < faxesToDelete.Length - 1; i++)
            {
                string[] documentName = faxesToDelete[i].Split('\\');
                Logging.LogErrors(ConfigurationValues.ErrorLogPath, "Begin Archive");
                archiveDocument.ArchiveTheDocument(documentName[documentName.Length - 1],faxesToDelete[i], Utility.GetUserName());
                Logging.LogErrors(ConfigurationValues.ErrorLogPath, "End Archive");

                try
                {
                    System.IO.File.Delete(faxesToDelete[i]);
                    folderRepository.DeleteFileInFolder(faxesToDelete[i]);
                }
                catch (Exception er)
                {
                    Logging.LogErrors(ConfigurationValues.ErrorLogPath, er.ToString());
                    return BadRequest(er.ToString());
                }

                try
                {
                    documentData.DeleteDocumentInFolder(faxesToDelete[i]);
                }
                catch (Exception er)
                {
                    Logging.LogErrors(ConfigurationValues.ErrorLogPath, er.ToString());
                    return BadRequest(er.ToString());
                }
            }
            return Ok();
        }
        // POST: api/Annotations
        public void Post([FromBody]Annotations value)
        {
            DocumentRepository documentData = new DocumentRepository();
            CurrentDocuments currentDocuments = documentData.GetCurrentDocumentPathPdf(Utility.GetUserName());
            string [] pathParts = currentDocuments.PathToCurrentPdfDocument.Split('\\');
            string tempPdfPath = string.Empty;

            for (int i = 0; i < pathParts.Length - 1 ; i++)
            {
                tempPdfPath = tempPdfPath + pathParts[i] + "\\";
            }

            tempPdfPath = tempPdfPath + "temp" + pathParts[pathParts.Length -1];

            System.IO.File.Copy(currentDocuments.PathToCurrentPdfDocument, tempPdfPath,true);
            try
            {
                PDFDoc inDoc = new PDFDoc(tempPdfPath);
                {
                   inDoc.InitSecurityHandler();

                    string str = value.Data;

                    using (FDFDoc fdoc = new FDFDoc(FDFDoc.CreateFromXFDF(str)))
                    {
                        inDoc.FDFMerge(fdoc);
                        inDoc.FlattenAnnotations();
                        inDoc.Save(currentDocuments.PathToCurrentPdfDocument, SDFDoc.SaveOptions.e_incremental);
                        //inDoc.Save(currentDocuments.PathToCurrentPdfDocument, SDFDoc.SaveOptions.e_linearized);
                    }
                }
            }
            catch (PDFNetException e)
            {
                Console.WriteLine(e.Message);
            }
        }
        public void ArchiveTheDocument(string documentName, string documentPath, string user)
        {
            DocumentRepository documentRepository = new DocumentRepository();
            Guid guid;
            // Create and display the value of two GUIDs.
            guid = Guid.NewGuid();

            string newDocumentName = guid.ToString() + ".pdf";
            //1.  Change the name of the document
            //2.  Insert into database
            //3.  Move the document to the archieve
            ArchivedDocument archiveDocument = new ArchivedDocument();

            archiveDocument.OldDocumentName = documentName;
            archiveDocument.OldDocumentPath = documentPath;
            archiveDocument.NewdocumentName = newDocumentName;
            archiveDocument.NewDocumentPath = System.Configuration.ConfigurationManager.AppSettings["archieveDocumentPath"]
                + newDocumentName;
            archiveDocument.DocumentUser = user;
            archiveDocument.DateCreated = DateTime.Now;
            documentRepository.ArchieveDocument(archiveDocument);

            File.Copy(archiveDocument.OldDocumentPath, archiveDocument.NewDocumentPath);
        }
        // GET: api/DeleteDocument
        public HttpResponseMessage Get(string id)
        {
            HttpResponseMessage result = new HttpResponseMessage(HttpStatusCode.OK);

            try
            {
                Logging.LogErrors(ConfigurationValues.ErrorLogPath, ConfigurationValues.PdfTronLicenseKey);

                PDFNet.Initialize(ConfigurationValues.PdfTronLicenseKey);
                PDFDoc documentToAdd = new PDFDoc();
                string xodFileName = Guid.NewGuid().ToString() + ".xod";
                string pdfFileName = xodFileName.Replace(".xod", ".pdf");

                string filePathXod = ConfigurationValues.PathToXodFile + xodFileName;
                string filePathPdf = ConfigurationValues.PathToXodFile + pdfFileName;
                PDFDoc newDocument = new PDFDoc();

                if (string.IsNullOrEmpty(id))
                {
                    try
                    {
                        File.Delete(filePathXod);
                    }
                    catch { }
                    File.Create(filePathXod).Dispose();
                    result = new HttpResponseMessage(HttpStatusCode.OK);
                    var stream = new FileStream(filePathXod, FileMode.Open);
                    result.Content = new StreamContent(stream);
                    result.Content.Headers.ContentType =
                        new MediaTypeHeaderValue("application/octet-stream");
                    result.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment")
                    {
                        FileName = ConfigurationValues.XodFileName
                    };
                    return result;
                }
                else
                {
                    string[] documents = id.Split('~');

                    for (int i = 0; i < documents.Length - 1; i++)
                    {
                        documentToAdd = new PDFDoc(documents[i]);
                        PageIterator itr = documentToAdd.GetPageIterator();
                        for (; itr.HasNext(); itr.Next())
                        {
                            try
                            {
                                pdftron.PDF.Page page = itr.Current();
                                newDocument.PageInsert(newDocument.GetPageIterator(itr.GetPageNumber()), page);
                            }
                            catch (Exception er)
                            {
                                Logging.LogErrors(ConfigurationValues.ErrorLogPath, er.ToString());
                            }
                        }
                    }
                    try
                    {
                        File.Delete(filePathXod);
                    }
                    catch { }

                    documentToAdd.Close();
                    documentToAdd.Dispose();
                    DocumentRepository documentData = new DocumentRepository();
                    documentData.AddUpdateCurrentDocument(Utility.GetUserName(), filePathXod, filePathPdf, id, documentData.GetFullPathToDocument(Utility.GetUserName()));
                    File.Create(filePathXod).Dispose();
                    newDocument.Save(filePathPdf, 0);

                    pdftron.Filters.Filter objFilter = pdftron.PDF.Convert.ToXod(newDocument);
                    System.Threading.Thread.Sleep(ConfigurationValues.XodSaveDelay);
                    objFilter.WriteToFile(filePathXod, true);
                    var stream = new FileStream(filePathXod, FileMode.Open);
                    result.Content = new StreamContent(stream);
                    result.Content.Headers.ContentType =
                        new MediaTypeHeaderValue("application/octet-stream");
                    result.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment")
                    {
                        FileName = ConfigurationValues.XodFileName
                    };
                    newDocument.Close();
                    newDocument.Dispose();
                }
                return result;
            }
            catch (Exception er)
            {
                Logging.LogErrors(ConfigurationValues.ErrorLogPath, er.ToString());
                return result;
            }
        }
        public void SendFileToAnotherUser(FaxFolders sendFileToAnotherUser)
        {
            //1.  Move the file to the new folder
            //2   Insert record giving folder that and name of document

            CurrentDocument currentdocument = new CurrentDocument();
            DocumentRepository documentRepository = new DocumentRepository();
            ArchiveDocument archiveDocument = new ArchiveDocument();

            try {

                using (IDbConnection db = new SqlConnection(ConfigurationValues.PostOfficeDatabaseConnection))
                {

                    string query = "SELECT [ID],[ActiveDirectoryUser],[CurrentDocumentPathXOD],[CurrentDocumentPathPDF]"
                        + " ,[PathToDocument],[CurrentAnnotation],[CurrentListOfDocuments]"
                        + " FROM [CurrentDocument]"
                        + " where [ActiveDirectoryUser] = @ActiveDirectoryUser";

                    currentdocument = db.Query<CurrentDocument>(query, new { @ActiveDirectoryUser = Utility.GetUserName() }).Single();

                    string[] filestoDelete = currentdocument.CurrentListOfDocuments.Split('~');
                    for (int i = 0; i < filestoDelete.Length - 1; i++)
                    {
                        string[] currentDocumentName = filestoDelete[i].Split('\\');
                        Logging.LogErrors(ConfigurationValues.ErrorLogPath, "The document name is: " + currentDocumentName[currentDocumentName.Length - 1]);
                        
                        archiveDocument.ArchiveTheDocument(currentDocumentName[currentDocumentName.Length - 1], filestoDelete[i], Utility.GetUserName());

                        File.Copy(filestoDelete[i], ConfigurationValues.InboundFaxRoot +  sendFileToAnotherUser.NewPath + "\\" + currentDocumentName[currentDocumentName.Length - 1]);

                        try
                        {
                            documentRepository.DeleteDocumentThatIsInAInFolder(filestoDelete[i], Utility.GetUserName());
                            try
                            {
                                File.Delete(filestoDelete[i]);
                            }
                            catch { }
                        }
                        catch (Exception er)
                        {
                            Logging.LogErrors(ConfigurationValues.ErrorLogPath, er.ToString());
                        }
                    }
                }
            }
            catch (Exception er)
            {
                Logging.LogErrors(ConfigurationValues.ErrorLogPath, er.ToString());
            }
        }
 // GET: api/CustomSignature
 public IEnumerable<Annotations> Get()
 {
     DocumentRepository documentData = new DocumentRepository();
     return documentData.GetCustomSignatures();
 }
        // GET: api/SeparatePDF/5
        public IHttpActionResult Get(string id)
        {
            try
            {

                id = id + ",";

                PDFNet.Initialize(ConfigurationValues.PdfTronLicenseKey);
                string[] pagesSeparationGroups = id.Split('~');
                string[] newPdfNames = new string[pagesSeparationGroups.Length - 1];
                PDFDoc[] newPdfDocs = new PDFDoc[pagesSeparationGroups.Length - 1];

                for (int i = 0; i < newPdfNames.Length; i++)
                {
                    newPdfNames[i] = Guid.NewGuid().ToString() + ".pdf";
                    newPdfDocs[i] = new PDFDoc();
                }

                DocumentRepository documentData = new DocumentRepository();

                CurrentDocuments currentDocuments = documentData.GetCurrentDocumentPathPdf(Utility.GetUserName());
                string[] currentDocumentCount = currentDocuments.CurrentDocumentList.Split('~');
                string[] currentDocumentList = currentDocumentCount[0].Split('\\');

                string pathToCurrentPdfFile = currentDocuments.PathToCurrentPdfDocument;

                string currentPdfPath = currentDocumentCount[0].Replace(currentDocumentList[currentDocumentList.Length - 1], "");

                PDFDoc separatePagesFromDocument = new PDFDoc(pathToCurrentPdfFile);

                for (int i = 0; i < pagesSeparationGroups.Length - 1; i++)
                {
                    string[] beginEndPageValues = pagesSeparationGroups[i].Split(',');

                    string pagesSeparationBegin = beginEndPageValues[0];
                    string pagesSeparationEnd = beginEndPageValues[1];

                    if (pagesSeparationBegin.Length > 0)
                    {
                        newPdfDocs[i].InsertPages(0, separatePagesFromDocument, int.Parse(pagesSeparationBegin), int.Parse(pagesSeparationEnd), PDFDoc.InsertFlag.e_none);
                        //newPdfDocs[i].Save(ConfigurationValues.OutboundFaxDirectory + "\\" + Utility.GetUserName() + "\\" + newPdfNames[i], 0);
                        newPdfDocs[i].Save(currentPdfPath + newPdfNames[i], 0);
                    }
                }

                separatePagesFromDocument.Close();
                separatePagesFromDocument.Dispose();
                File.Delete(currentDocumentCount[0]);


                for (int i = 0; i < newPdfNames.Length; i++)
                {
                    newPdfDocs[i].Close();
                    newPdfDocs[i].Dispose();
                }

                string[] deleteTheDocumentList = currentDocuments.CurrentDocumentList.Split('~');
                for (int i = 0; i < deleteTheDocumentList.Length - 1; i++)
                {
                    try
                    {
                        File.Delete(ConfigurationValues.OutboundFaxDirectory + "\\" + Utility.GetUserName() + "\\" + deleteTheDocumentList[i]);
                    }
                    catch { }
                }
                // ConfigurationValues.OutboundFaxDirectory + "\\" + Utility.GetUserName() + "\\"
                return Ok();
            }
            catch
            {
                return BadRequest("Error in splitting document.  Please try again");
            }
        }
        // POST: api/SendFax
        public IHttpActionResult Post([FromBody] Fax faxValues)
        {
            System.IO.Directory.CreateDirectory(ConfigurationValues.TemporaryFaxPath
                        + Utility.GetUserName());

            Logging.LogErrors(ConfigurationValues.ErrorLogPath, "Start Creating Fax");

            OperationResult createFaxRecordOperationResult = new Models.OperationResult();
            OperationResult sendFaxToMultiTechOperationResult = new Models.OperationResult();

            FaxRepository faxData = new FaxRepository();
            DocumentRepository documentData = new DocumentRepository();

            string[] faxesToSendList = faxValues.FaxTo.Split('~');

            SendFax sendFax = new SendFax();

            try
            {
                for (int i = 0; i < faxesToSendList.Length - 1; i++)
                {

                    Logging.LogErrors(ConfigurationValues.ErrorLogPath, "Getting fax information");

                    FaxingInformation faxingInformatonInitial = new FaxingInformation();

                    faxingInformatonInitial.DocumentList = faxValues.DocumentList;
                    faxingInformatonInitial.FaxTo = faxesToSendList[i];
                    faxingInformatonInitial.Notes = faxValues.Notes;
                    faxingInformatonInitial.From = faxValues.From;
                    faxingInformatonInitial.Cover = faxValues.Cover;
                    faxingInformatonInitial.CoverSheetOnly = faxValues.CoverOnly;

                    Logging.LogErrors(ConfigurationValues.ErrorLogPath, "Getting fax information");                    
                    //Create Fax
                    FaxingInformation faxingInformatonComplete = sendFax.CreateFax(faxingInformatonInitial);

                    System.IO.File.Copy(ConfigurationValues.TemporaryFaxPath
                        + Utility.GetUserName() + "\\" + faxingInformatonComplete.FaxName,
                        ConfigurationValues.PernamentFaxPath
                        + faxingInformatonComplete.FaxName, true);

                    createFaxRecordOperationResult = faxData.SendFax(faxingInformatonComplete, ConfigurationValues.PernamentFaxPath
                        + faxingInformatonComplete.FaxName, faxValues.From, faxValues.Notes);

                    if (createFaxRecordOperationResult.Success)
                    {
                        sendFaxToMultiTechOperationResult = sendFaxMultitech.SendTheFax(faxingInformatonComplete.Name, faxingInformatonComplete.FaxPath,
                            faxValues.From, faxingInformatonComplete.FaxNumber, createFaxRecordOperationResult.MessageList[0], ConfigurationValues.ApplicationPath);
                        if (sendFaxToMultiTechOperationResult.Success)
                        {
                            if (faxValues.SendToEmr == "F")
                            {
                                ArchiveDocument = new ArchiveDocument();

                                CurrentDocuments faxTodocument = documentData.GetCurrentDocumentPathPdf(Utility.GetUserName());
                                string[] filesToDelete = faxTodocument.CurrentDocumentList.Split('~');
                                for (int j = 0; j < filesToDelete.Length - 1; j++)
                                {
                                    try
                                    {
                                        string[] fileParts = filesToDelete[j].Split('\\');

                                        ArchiveDocument.ArchiveTheDocument(fileParts[fileParts.Length - 1], filesToDelete[j], Utility.GetUserName());

                                        File.Delete(filesToDelete[j]);
                                    }
                                    catch { }

                                    documentData.DeleteDocumentInFolder(filesToDelete[j]);
                                }


                                Logging.LogErrors(ConfigurationValues.ErrorLogPath, "Begin Delete file");

                                File.Delete(faxingInformatonComplete.FaxPath);

                                File.Delete(ConfigurationValues.TemporaryFaxPath
                                    + Utility.GetUserName()
                                    + "\\cover.pdf");
                                Logging.LogErrors(ConfigurationValues.ErrorLogPath, "end delete file");

                            }
                        }
                        else
                        {
                            faxData.UpdateFaxRecord(sendFaxToMultiTechOperationResult.MessageList[0]);
                            return BadRequest(sendFaxToMultiTechOperationResult.MessageList[0]);
                        }
                    }
                    else
                    {
                        return BadRequest(createFaxRecordOperationResult.MessageList[0]);
                    }
                }
            }
            catch (Exception er)
            {
                return BadRequest(er.ToString());
            }

            CurrentDocuments documentsToDelete = documentData.GetCurrentDocumentPathPdf(Utility.GetUserName());

            try
            {
                File.Delete(documentData.GetFullPathToDocument(Utility.GetUserName()));
            }
            catch { }

            string[] faxesToDelete = documentsToDelete.CurrentDocumentList.Split('~');

            try
            {
                for (int i = 0; i < faxesToDelete.Length - 1; i++)
                {
                    System.IO.File.Delete(ConfigurationValues.OutboundFaxDirectory + "\\"
                        + Utility.GetUserName() + "\\"
                        + faxesToDelete[i]);
                }
            }
            catch { }
            return Ok();
        }
        public FaxingInformation CreateFax(FaxingInformation faxingInformation)
        {
            string temporaryPath = string.Empty;

            faxingInformation.FaxName
                = Guid.NewGuid().ToString() + ".pdf";

            FaxRepository faxData = new FaxRepository();
            string[] firstFaxTo = faxingInformation.FaxTo.Split('~');
            List<FaxToInformation> data = new List<FaxToInformation>();

            if (faxingInformation.FaxTo.Substring(0, 1) == "G")
            {
                data = faxData.GetFaxToInformationGreenway(firstFaxTo[0]);
            }
            else
            {
                data = faxData.GetFaxToInformation(firstFaxTo[0]);
            }

            try
            {
                faxingInformation.FaxTo = data[0].Name;

            }
            catch
            {

            }
            try
            {
                DocumentRepository documentData = new DocumentRepository();
                CurrentDocuments faxTodocument = documentData.GetCurrentDocumentPathPdf(Utility.GetUserName());
                Logging.LogErrors(ConfigurationValues.ErrorLogPath, faxTodocument.PathToCurrentPdfDocument);                    
                MemoryStream newPdfStream = Utility.CreateMemoryStreamFromPdf(faxTodocument.PathToCurrentPdfDocument);

                temporaryPath = ConfigurationValues.TemporaryFaxPath + Utility.GetUserName() + "\\"
                    + faxingInformation.FaxName;

                Logging.LogErrors(ConfigurationValues.ErrorLogPath, temporaryPath);                    
                FileStream newPdfStreamFile = new FileStream(temporaryPath, FileMode.Create);

                newPdfStream.WriteTo(newPdfStreamFile);
                Logging.LogErrors(ConfigurationValues.ErrorLogPath, "writing to file");                    
                newPdfStream.Close();
                Logging.LogErrors(ConfigurationValues.ErrorLogPath, "Closing stream");                    
                newPdfStreamFile.Close();

                MemoryStream coverSheet
                    = CreateCoverSheetV2(faxingInformation.FaxTo, data[0].FaxNumber, Utility.GetPDFPageCount(newPdfStreamFile.Name),
                    faxingInformation.Notes, faxingInformation.From, int.Parse(faxingInformation.Cover));

                faxingInformation.PageCount = Utility.GetPDFPageCount(newPdfStreamFile.Name);
                faxingInformation.FaxNumber = UpdatedFaxNumber(data[0].FaxNumber);
                faxingInformation.Name = faxingInformation.FaxTo;

                FileStream presStream = new FileStream(ConfigurationValues.TemporaryFaxPath + Utility.GetUserName()
                    + "\\cover.pdf", FileMode.Create);
                coverSheet.WriteTo(presStream);
                coverSheet.Close();
                presStream.Close();
                if (faxingInformation.CoverSheetOnly == "T")
                {
                    File.Copy(ConfigurationValues.TemporaryFaxPath + Utility.GetUserName()
                            + "\\cover.pdf", newPdfStreamFile.Name, true);
                    File.Delete(ConfigurationValues.TemporaryFaxPath + Utility.GetUserName()
                            + "\\cover.pdf");
                }
                else
                {
                    Utility.MergeTwoPDFDocuments(ConfigurationValues.TemporaryFaxPath + Utility.GetUserName()
                       + "\\cover.pdf", newPdfStreamFile.Name);
                }

                faxingInformation.FaxPath = newPdfStreamFile.Name;

                return faxingInformation;
            }
            catch (Exception er)
            {
                Logging.LogErrors(ConfigurationValues.ErrorLogPath, er.ToString());
                return faxingInformation;
            }
        }
 // GET: api/Annotations
 public HttpResponseMessage Get()
 {
     DocumentRepository documentData = new DocumentRepository();
     string xmlContent = documentData.GetAnnotation(Utility.GetUserName());
     return new HttpResponseMessage() { Content = new StringContent(xmlContent, Encoding.UTF8, "application/xml") };
 }