/// <summary>
 /// Creates content of CSV file representing current table.
 /// </summary>
 /// <param name="model">Model for current table.</param>
 /// <returns>Content of file that will be sent on "Export" button click.</returns>
 public static String CreateExportData(TableModel model)
 {
     List<String[]> projects = new List<String[]>();
     foreach (ProjectModel project in model.Projects)
     {
         String[] propertiesForOne = new String[model.Headers.Length];
         for (int i = 0; i < project.Properties.Length; i++)
         {
             propertiesForOne[i] = MakeForCSV(project.Properties[i]);
         }
         projects.Add(propertiesForOne);
     }
     return FormCSVFile(model.Headers, projects.ToArray());
 }
 public ActionResult EditTable(String filter, TableModel model)
 {
     return RedirectToAction("Index", new { filter = filter, tableDefinition = model.TableDefinition });
 }
 /// <summary>
 /// Creates all necessary data for Table.ascx
 /// </summary>
 /// <param name="tableDefinition">User-defined table view from request</param>
 /// <returns>Model for Table.ascx</returns>
 public static TableModel CreateTableModel(String filter, String tableDefinition, HttpContextBase context)
 {
     TableModel model = new TableModel();
     ColumnDefinition[] columns = ParseForColumns(tableDefinition, context);
     model.Headers = columns.Select(x => x.Header).ToArray();
     model.Width = columns.Select(x => x.Width).ToArray();
     model.TableDefinition = tableDefinition;
     model.Filter = filter;
     model.Projects = GetProjectModels(columns, filter, tableDefinition, context.User);
     return model;
 }
 public void CreateExportDataTest()
 {
     TableModel model = new TableModel();
     String[] headers = { "Header1", "Header2", "Header3" };
     model.Headers = headers;
     model.Projects =new ProjectModel[] { new ProjectModel {Properties= new String[]{ "1", "2", "3"} }, new ProjectModel {Properties=new String[]{ "4", "5", "6"} } };
     string expected = "Header1;Header2;Header3;\n1;2;3;\n4;5;6;\n";
     string actual;
     actual = ProjectsHelper.CreateExportData(model);
     Assert.AreEqual(expected, actual);
 }