initial source commit

This commit is contained in:
Gary Sharp
2013-02-01 12:35:28 +11:00
parent 543a005d31
commit 0a93429800
1103 changed files with 285609 additions and 0 deletions
@@ -0,0 +1,30 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Mvc;
using Disco.Models.Repository;
namespace Disco.Web.Extensions
{
public static class JobSubTypeExtensions
{
public static List<SelectListItem> ToSelectListItems(this IEnumerable<JobSubType> jobSubTypes, List<JobSubType> SelectedItems)
{
List<string> selectedIds = default(List<string>);
if (SelectedItems != null)
selectedIds = SelectedItems.Select(i => string.Format("{0}_{1}", i.JobTypeId, i.Id)).ToList();
return jobSubTypes.ToSelectListItems(selectedIds);
}
public static List<SelectListItem> ToSelectListItems(this IEnumerable<JobSubType> jobSubTypes, List<string> SelectedIds = null)
{
if (SelectedIds == null)
return jobSubTypes.Select(jst => new SelectListItem { Value = string.Format("{0}_{1}", jst.JobTypeId, jst.Id), Text = jst.Description }).ToList();
else
return jobSubTypes.Select(jst => new SelectListItem { Value = string.Format("{0}_{1}", jst.JobTypeId, jst.Id), Text = jst.Description, Selected = (SelectedIds.Contains(string.Format("{0}_{1}", jst.JobTypeId, jst.Id))) }).ToList();
}
}
}