feature: job exporting (resolves #155)

This commit is contained in:
Gary Sharp
2024-12-12 16:02:12 +11:00
parent 90c709c4c1
commit a6b9cd1af2
55 changed files with 3197 additions and 412 deletions
@@ -111,6 +111,7 @@
<Compile Include="MvcExtensions\PartialCompiled\PartialCompiledHtmlExtensions.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="MvcExtensions\XmlResult.cs" />
<Compile Include="RazorExtensions\DropDownListExtensions.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Disco.BI\Disco.BI.csproj">
@@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Web.Mvc.Html;
using System.Web.Mvc;
namespace Disco.Web.Extensions
{
public static class DropDownListExtensions
{
public static MvcHtmlString DropDownListFor<TModel, TObject, TProperty>(this HtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TProperty>> expression, Func<TModel, IEnumerable<TObject>> source, Func<TObject, string> valueGenerator, Func<TObject, string> textGenerator, string instructionMessage = null)
{
var selectList = source(htmlHelper.ViewData.Model)
.Select(i => new SelectListItem() { Value = valueGenerator(i), Text = textGenerator(i) });
if (instructionMessage != null)
{
selectList = new SelectListItem[]
{ new SelectListItem { Text = instructionMessage, Value = string.Empty } }
.Concat(selectList);
}
return htmlHelper.DropDownListFor(expression, selectList);
}
}
}