public OperationResult AddFolder(Folder folder) { OperationResult operationResult = new Models.OperationResult(); using (IDbConnection db = new SqlConnection(ConfigurationValues.PostOfficeDatabaseConnection)) { try { const string query = "INSERT INTO [HoldFolders]" + " (" + " [ActiveDirectoyUser]" + " ,[DocumentType]" + " ,[FolderName]" + " )" + "VALUES" + " (" + " @ActiveDirectoyUser,@DocumentType,@FolderName" + " )"; int rowsAffectd = db.Execute(query, new { @ActiveDirectoyUser = Utility.GetUserName(), @DocumentType = folder.DocumentType, @FolderName = folder.FolderName }); operationResult.Success = true; return operationResult; } catch (Exception er) { operationResult.Success = false; operationResult.AddMessage(er.ToString()); return operationResult; } } }
//public List<Folder> GetFolders(string folderType) //{ // List<Folder> folderList = new List<Folder>(); // List<Folder> folderList2 = new List<Folder>(); // Folder folder = new Folder(); // folder.Id = 0; // folder.FolderName = "Select Folder"; // folderList2.Add(folder); // try // { // string query = "SELECT [ID],[FolderName]" // + " FROM [HoldFolders]" // + " where [ActiveDirectoyUser] = @ActiveDirectoyUser" // + " and documentType = @documentType"; // using (SqlConnection db = new SqlConnection(ConfigurationValues.PostOfficeDatabaseConnection)) // { // folderList = db.Query<Folder>(query, new // { // @ActiveDirectoyUser = Utility.GetUserName(), // @documentType = folderType // }).ToList(); // for (int i = 0; i < folderList.Count; i++) // { // folderList2.Add(folderList[i]); // } // return folderList2; // } // } // catch (Exception er) // { // Logging.LogErrors(ConfigurationValues.ErrorLogPath, er.ToString()); // return folderList2; // } //} public List<FaxFolders> GetSendToNames(string friendlyName) { List<FaxFolders> faxFoldersList = new List<FaxFolders>(); List<FaxFolders> faxFoldersList2 = new List<FaxFolders>(); FaxFolders faxFolders = new Models.FaxFolders(); faxFolders.ID = 0; faxFolders.FriendlyName = "Send To"; faxFoldersList2.Add(faxFolders); Folder folder = new Folder(); // folder.Id = 0; // folder.FolderName = "Select Folder"; // folderList2.Add(folder); try { using (IDbConnection db = new SqlConnection(ConfigurationValues.PostOfficeDatabaseConnection)) { string query = "SELECT [ID],[FriendlyName],[NewPath]" + " FROM [PostOfficeFolders]" + " where [FriendlyName] Like '%" + friendlyName + "%'" + " order by [FriendlyName]"; faxFoldersList = db.Query<FaxFolders>(query).ToList(); for (int i = 0; i < faxFoldersList.Count; i++) { faxFoldersList2.Add(faxFoldersList[i]); } return faxFoldersList2; } } catch (Exception er) { Logging.LogErrors(ConfigurationValues.ErrorLogPath, er.ToString()); return faxFoldersList2; } }
public List<Folder> GetFolders(string folderType) { List<Folder> folderList = new List<Folder>(); List<Folder> folderList2 = new List<Folder>(); Folder folder = new Folder(); folder.Id = 0; folder.FolderName = "Select Folder"; folderList2.Add(folder); try { string query = "SELECT [ID],[FolderName]" + " FROM [HoldFolders]" + " where [ActiveDirectoyUser] = @ActiveDirectoyUser" + " and documentType = @documentType"; using (SqlConnection db = new SqlConnection(ConfigurationValues.PostOfficeDatabaseConnection)) { folderList = db.Query<Folder>(query, new { @ActiveDirectoyUser = Utility.GetUserName(), @documentType = folderType }).ToList(); for (int i = 0; i < folderList.Count; i++) { folderList2.Add(folderList[i]); } return folderList2; } } catch (Exception er) { Logging.LogErrors(ConfigurationValues.ErrorLogPath, er.ToString()); return folderList2; } }