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);
        }
        public void ArchieveDocument(ArchivedDocument archivedDocument)
        {
            using (IDbConnection db = new SqlConnection(ConfigurationValues.PostOfficeDatabaseConnection))
            {
                try
                {
                    const string query = "INSERT INTO [DocumentArchive]"
                        + " ("
                        + "[OldDocumentName]"
                        + " ,[NewdocumentName]"
                        + " ,[OldDocumentPath]"
                        + " ,[NewDocumentPath]"
                        + " ,[DocumentUser]"
                        + " ,[DateCreated]"
                        + " )"
                        + " VALUES"
                        + " ("
                        + " @OldDocumentName,@NewdocumentName,@OldDocumentPath,@NewDocumentPath,@DocumentUser,@DateCreated"
                        + ")";

                    int rowsAffectd = db.Execute(query, new
                    {
                        @OldDocumentName = archivedDocument.OldDocumentName,
                        @NewdocumentName = archivedDocument.NewdocumentName,
                        @OldDocumentPath = archivedDocument.OldDocumentPath,
                        @NewDocumentPath = archivedDocument.NewDocumentPath,
                        @DocumentUser = archivedDocument.DocumentUser,
                        @DateCreated = archivedDocument.DateCreated
                    });
                }
                catch (Exception er)
                {
                    Logging.LogErrors(ConfigurationValues.ErrorLogPath, er.ToString());
                }
            }
        }