public OperationResult AddPostOfficeFolders(List<FaxFolders> faxFoldersList)
        {
            FaxFolders faxFoldersFullInformation = new FaxFolders();

            DeleteCurrentList(Utility.GetUserName());

            OperationResult operationResult = new OperationResult();

            for (int i = 0; i < faxFoldersList.Count; i++)
            {
                faxFoldersFullInformation = GetFaxingData(faxFoldersList[i].FriendlyName);

                try
                {

                    string query = "INSERT INTO [PostOfficeFoldersByUser]"
                        + " ("
                        + " [ActiveDirectoyUser]"
                        + " ,[Path]"
                        + " ,[Name]"
                        + " )"
                        + " VALUES"
                        + " ("
                        + "@ActiveDirectoyUser,@Path,@Name"
                        + " )";

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

                            int rowsAffectd = db.Execute(query, new
                            {
                                @ActiveDirectoyUser = Utility.GetUserName(),
                                @Path = faxFoldersFullInformation.NewPath,
                                @Name = faxFoldersFullInformation.FriendlyName
                            }
                                );
                        }
                    }

                }
                catch (Exception er)
                {
                    operationResult.Success = false;
                    operationResult.AddMessage(er.Message);
                    return operationResult;
                }

            }

            operationResult.Success = true;
            operationResult.ErrorMessage = "None";
            return operationResult;
        }
        public List<FaxFolders> GetFaxFolders()
        {
            List<FaxFolders> faxFolderList = new List<FaxFolders>();
            List<FaxFolders> faxFolderList2 = new List<FaxFolders>();
            FaxFolders faxFolder = new FaxFolders();
            faxFolder.ID = 0;
            faxFolder.FriendlyName = "Select Folder";
            faxFolder.PhoneNumber = string.Empty;
            faxFolder.NewPath = string.Empty;
            faxFolderList2.Add(faxFolder);

            try
            {
                string query = "SELECT [ID],[FriendlyName],[NewPath]"
                    + " FROM [PostOfficeFolders]"
                    + " order by [FriendlyName]";

                using (SqlConnection db = new SqlConnection(ConfigurationValues.PostOfficeDatabaseConnection))
                {
                    faxFolderList = db.Query<FaxFolders>(query).ToList();

                    for (int i = 0; i < faxFolderList.Count; i++)
                    {
                        faxFolderList2.Add(faxFolderList[i]);

                    }
                    return faxFolderList2;
                }

            }
            catch (Exception er)
            {
                Logging.LogErrors(ConfigurationValues.ErrorLogPath, er.ToString());
                return faxFolderList2;
            }
        }
        private FaxFolders GetFaxingData(string friendlyName)
        {
            FaxFolders faxFolders = new FaxFolders();

            try
            {
                using (IDbConnection db = new SqlConnection(ConfigurationValues.PostOfficeDatabaseConnection))
                {
                    string query = "SELECT [ID],[FriendlyName],[NewPath]"
                        + " FROM [PostOfficeFolders]"
                        + " where [FriendlyName] = @FriendlyName";

                    faxFolders = db.Query<FaxFolders>(query, new { @FriendlyName = friendlyName }).Single();
                    return faxFolders;
                }
            }
            catch (Exception er)
            {
                Logging.LogErrors(ConfigurationValues.ErrorLogPath, er.ToString());
                return faxFolders;
            }
        }
        public void SendFileToAnotherUser(FaxFolders sendFileToAnotherUser)
        {
            //1.  Move the file to the new folder
            //2   Insert record giving folder that and name of document
            string s1 = string.Empty;

            CurrentDocument currentdocument = new CurrentDocument();
            List<OutboundFaxDocument> outboundFaxDocumentList = new List<OutboundFaxDocument>();
            DocumentRepository documentRepository = new DocumentRepository();
            ArchiveDocument archiveDocument = new ArchiveDocument();

            try {

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

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

                    currentdocument = db.Query<CurrentDocument>(query, new { @ActiveDirectoyUser = Utility.GetUserName() }).Single();
                    //File.Move(currentdocument.CurrentDocumentPathPDF, sendFileToAnotherUser.NewPath + "\\" + currentdocumentName[currentdocumentName.Length - 1]);

                    string[] filestoDelete = currentdocument.CurrentListOfDocuments.Split('~');
                    for (int i = 0; i < filestoDelete.Length - 1; i++)
                    {
                        string[] currentDocumentName = filestoDelete[i].Split('\\');

                        archiveDocument.ArchiveTheDocument(currentDocumentName[currentDocumentName.Length - 1], filestoDelete[i], Utility.GetUserName());

                        File.Move(filestoDelete[i], 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());
            }
        }