public ActionResult Search(int?dataSourceID = null) { DataRegistrySearchViewModel viewModel = new DataRegistrySearchViewModel(); viewModel.DataSourceID = dataSourceID; return(View(viewModel)); }
public ActionResult Search(DataRegistrySearchViewModel viewModel, FormCollection form, string commandParameter) { if (viewModel == null) { viewModel = new DataRegistrySearchViewModel(); } if (!string.IsNullOrWhiteSpace(commandParameter) && commandParameter.ToLower().Trim().Contains("export")) { var data = Repository.DataRegistry.DataElements.GridSearch(viewModel.DataSourceID, viewModel.DataContainerID, viewModel.DataContainerTableID, viewModel.Keywords, viewModel.XMLTag, viewModel.Identifier, viewModel.RegistryFieldNumber); //lets make a filename based on the dictionary name and the date. DateTime fSuffix = DateTime.Now; string fileName = ""; if (viewModel.DataSourceID.HasValue) { var dataSource = Repository.DataRegistry.DataSources.GetByID(viewModel.DataSourceID.Value); if (dataSource != null) { fileName += dataSource.Acronym + "_"; } } fileName += fSuffix.Month + "-" + fSuffix.Day + "-" + fSuffix.Year; fileName = "CDR_" + fileName + ".xlsx"; ExcelColumnMappingCollection mappings = new ExcelColumnMappingCollection(); mappings.Add("Identifier", "Identifier"); mappings.Add("Section", "Section"); mappings.Add("FieldName", "Field Name"); mappings.Add("RegistryFieldNumber", "Registry Field Number"); mappings.Add("CodeArray", "Codes/Criteria"); mappings.Add("Length", "Length"); mappings.Add("Type", "Type"); mappings.Add("Description", "Description"); mappings.Add("XMLTag", "XML Tag"); mappings.Add("FieldFormat", "Field Format"); mappings.Add("Obsolete", "Obsolete"); ExportToExcel(fileName, data, mappings); } return(View(viewModel)); }