public async Task <Object> ExportAllBusinessUsers(Guid businessID, string fileType) { try { string downloadUrl = null; string folder = FoldersNames.ExportedData; var businessId = new Npgsql.NpgsqlParameter("@thebusinessid", businessID); var listOfBusinessUsersToExport = await Task.Run(() => _projectContextDB.ExportBusinessUsersModel. FromSqlRaw("select * from exportallbusinessusers(@thebusinessid)", businessId) .Select(e => new ExportBusinessUsersModel() { BusinessName = e.BusinessName, UserName = e.UserName }).ToList()); if (fileType.ToLower() == "excel") { downloadUrl = _commonLogic.ExportToExcel(listOfBusinessUsersToExport, folder); } //create a datatable of this data var listOfBusinessUsersInDataTable = _commonLogic.ToDataTable(listOfBusinessUsersToExport); if (fileType.ToLower() == "csv") { downloadUrl = _commonLogic.ExportToCsv(listOfBusinessUsersInDataTable, folder); } if (fileType.ToLower() == "pdf") { downloadUrl = _commonLogic.ExportToPdf(listOfBusinessUsersInDataTable, folder); } var exportedData = new { Success = "OK", Data = downloadUrl }; return(exportedData); } catch (Exception e) { return(null); } }
public async Task <Object> ExportAllUsers(string fileType) { try { string downloadUrl = null; string folder = FoldersNames.ExportedData; var listOfUsersToBeExported = await Task.Run(() => _projectContextDB.ExportUserModel .FromSqlRaw("select * from Exportallusers()") .Select(e => new ExportUserModel() { UserName = e.UserName, UserFirstName = e.UserFirstName, UserLastName = e.UserLastName, UserEmail = e.UserEmail, UserContact = e.UserContact }).ToList()); if (fileType.ToLower() == "excel") { downloadUrl = _commonLogic.ExportToExcel(listOfUsersToBeExported, folder); } var listOfUserInDataTable = _commonLogic.ToDataTable(listOfUsersToBeExported); if (fileType.ToLower() == "csv") { downloadUrl = _commonLogic.ExportToCsv(listOfUserInDataTable, folder); } if (fileType.ToLower() == "pdf") { downloadUrl = _commonLogic.ExportToPdf(listOfUserInDataTable, folder); } var exportedData = new { Success = "OK", Data = downloadUrl }; return(exportedData); } catch (Exception e) { return(null); } }
public async Task <object> ExportAllEmployees(Guid businessID, string fileType) { try { string downlaodUrl = null; string folder = FoldersNames.ExportedData; var businessId = new Npgsql.NpgsqlParameter("@thebusinessid", businessID); var listOfEmployeesDataToBeExport = await Task.Run(() => _projectContextDB.ExportEmployeeModels. FromSqlRaw("select * from exportallemployees(@thebusinessid)", businessId) .Select(e => new ExportEmployeeModel() { EmployeeName = e.EmployeeName, EmployeeGender = e.EmployeeGender, EmployeeSSN = e.EmployeeSSN, DepartmentName = e.DepartmentName, CreationDate = Convert.ToString(e.CreationDate), Status = e.Status, BPS = e.BPS, EmpDesignation = e.EmpDesignation, PACountry = e.PACountry, PACity = e.PACity, PAProvince = e.PAProvince, PAZip = e.PAZip, MACountry = e.MACountry, MACity = e.MACity, MAProvince = e.MAProvince, MAZip = e.MAZip, EmpEmail = e.EmpEmail, EmpJoiningDate = Convert.ToString(e.EmpJoiningDate), EmpAppointmentDate = Convert.ToString(e.EmpAppointmentDate), Description = e.Description, Photo = e.Photo, SkypeUserName = e.SkypeUserName, EmpOfficeNo = e.EmpOfficeNo, EmpCellNo = e.EmpCellNo }).ToList()); if (fileType.ToLower() == "excel") { downlaodUrl = _commonLogic.ExportToExcel(listOfEmployeesDataToBeExport, folder); } //create a datatable of this data var listOfemployeesInDataTable = _commonLogic.ToDataTable(listOfEmployeesDataToBeExport); if (fileType.ToLower() == "csv") { downlaodUrl = _commonLogic.ExportToCsv(listOfemployeesInDataTable, folder); } if (fileType.ToLower() == "pdf") { downlaodUrl = _commonLogic.ExportToPdf(listOfemployeesInDataTable, folder); } var exportedData = new { Success = "OK", Data = downlaodUrl }; return(exportedData); } catch (Exception e) { return(null); } }