public OperationResult AddFaxAddressbookEntry(FaxToInformation faxToInformation)
        {
            OperationResult operationResult = new OperationResult();
            try
            {
                string query = "INSERT INTO [FaxSendingInformation]("
                    + "[AccountID],[FirstName],[LastName],[Name],[FaxNumber],[Prefix],[Suffix]"
                    + ")VALUES("
                    + "@AccountID,@FirstName,@LastName,@Name,@FaxNumber,@Prefix,@Suffix)";

                using (SqlConnection db = new SqlConnection(ConfigurationValues.WaldenFaxConnection))
                {
                    int rowsAffectd = db.Execute(query, new
                    {
                        @AccountID = "1001",
                        @FirstName = faxToInformation.FirstName,
                        @LastName = faxToInformation.LastName,
                        @Name = faxToInformation.Name,
                        @FaxNumber = faxToInformation.FaxNumber,
                        @Prefix = faxToInformation.Prefix,
                        @Suffix = faxToInformation.Suffix
                    }
                        );
                }

                operationResult.Success = true;
                return operationResult;
            }
            catch (Exception er)
            {
                operationResult.Success = false;
                operationResult.AddMessage(er.Message);
                return operationResult;
            }
        }
        //public MiscFaxInformation CreateFax(string faxDocumentList, string _faxTo, string notes,
         //   string from, string cover)
        public FaxingInformation CreateFax(FaxingInformation faxingInformation)
        {
            //MiscFaxInformation miscFaxInformation = new MiscFaxInformation();

            string newPDF = string.Empty;
            string temporaryPath = string.Empty;

            faxingInformation.NameFromDateTimeString
                = Utility.GetFileNameFromDateTimeString() + ".pdf";

            //var repository = new WaldenCompleteFaxWeb.Repository.FaxToInformation();
            var repository = new EmployeeDesktop.API.Models.FaxToInformation();

            FaxData faxData = new FaxData();
            //string[] FirstFaxTo = faxingInformation.FaxTo.Split('~');

            var data = faxData.GetFaxToInformation(faxingInformation.FaxTo);
            try
            {
                faxingInformation.FaxTo = data[0].Name;

            }
            catch
            {

            }
            try
            {
                StringCollection listOfPSFiles = new StringCollection();

                string[] words = faxingInformation.DocumentList.Split('~');

                for (int i = 0; i < words.Length; i++)
                {
                    if (words[i].Length > 0)
                    {
                        listOfPSFiles.Add(words[i]);
                    }
                }

                MemoryStream newPDFStream = CreatePreviewFax(listOfPSFiles);

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

                FileStream newPDFStreamFile = new FileStream(temporaryPath, FileMode.Create);

                newPDFStream.WriteTo(newPDFStreamFile);
                newPDFStream.Close();
                newPDFStreamFile.Close();

                MemoryStream coverSheet
                    = CreateCoverSheetV2(faxingInformation.FaxTo, data[0].FaxNumber, Walden.Medical.Library.Pdf.GetPDFPageCount(newPDFStreamFile.Name),
                    faxingInformation.Notes, faxingInformation.From, int.Parse(faxingInformation.Cover));


                //miscFaxInformation.PageCount = Walden.Medical.Library.Pdf.GetPDFPageCount(_newPDFStreamFile.Name);
                //miscFaxInformation.FaxNumber =  UpdatedFaxNumber(data[0].FaxNumber);
                //miscFaxInformation.Name = faxTo;

                faxingInformation.PageCount = Walden.Medical.Library.Pdf.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();

                Walden.Medical.Library.Pdf.MergeTwoDocuments(ConfigurationValues.TemporaryFaxPath + Utility.GetUserName()
                    + "\\cover.pdf", newPDFStreamFile.Name);

                faxingInformation.FaxPath = newPDFStreamFile.Name;
                //miscFaxInformation.FaxPath = _newPDFStreamFile.Name;

                return faxingInformation;
            }
            catch (Exception er)
            {
               EmployeeDesktop.API.Exceptions.ExceptionHandling.InsertErrorMessage(er.ToString());
               EmployeeDesktop.API.Exceptions.ExceptionHandling.SendErrorEmail(er.ToString(), ConfigurationValues.EmailFromFriendly, ConfigurationValues.EmailSendToFriendly, ConfigurationValues.EmailSubject);
                return faxingInformation;
            }
        }