initial source commit
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Web.Mvc;
|
||||
using Disco.Services.Plugins;
|
||||
|
||||
namespace Disco.Web.Extensions
|
||||
{
|
||||
public static class DiscoPluginDefinitionExtensions
|
||||
{
|
||||
public static List<SelectListItem> ToSelectListItems(this IEnumerable<PluginFeatureManifest> PluginFeatureDefinitions, PluginFeatureManifest SelectedItem)
|
||||
{
|
||||
string selectedId = default(string);
|
||||
|
||||
if (SelectedItem != null)
|
||||
selectedId = SelectedItem.Id;
|
||||
|
||||
return PluginFeatureDefinitions.ToSelectListItems(selectedId);
|
||||
}
|
||||
|
||||
public static List<SelectListItem> ToSelectListItems(this IEnumerable<PluginFeatureManifest> PluginDefinitions, string SelectedId = null, bool IncludeInstructionFirst = false, string InstructionMessage = "Select a Plugin")
|
||||
{
|
||||
var selectItems = default(List<SelectListItem>);
|
||||
if (SelectedId == null)
|
||||
selectItems = PluginDefinitions.Select(wpd => new SelectListItem { Value = wpd.Id, Text = wpd.Name }).ToList();
|
||||
else
|
||||
selectItems = PluginDefinitions.Select(wpd => new SelectListItem { Value = wpd.Id, Text = wpd.Name, Selected = (SelectedId.Equals(wpd.Id)) }).ToList();
|
||||
|
||||
if (IncludeInstructionFirst)
|
||||
selectItems.Insert(0, new SelectListItem() { Value = String.Empty, Text = String.Format("<{0}>", InstructionMessage), Selected = String.IsNullOrEmpty(SelectedId) });
|
||||
|
||||
return selectItems;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Web.Mvc;
|
||||
using Disco.Models.BI.Config;
|
||||
|
||||
namespace Disco.Web.Extensions
|
||||
{
|
||||
public static class OrganisationAddressExtensions
|
||||
{
|
||||
public static List<SelectListItem> ToSelectListItems(this IEnumerable<OrganisationAddress> organisationAddressess, OrganisationAddress SelectedItem)
|
||||
{
|
||||
int? selectedId = default(int?);
|
||||
|
||||
if (SelectedItem != null)
|
||||
selectedId = SelectedItem.Id;
|
||||
|
||||
return organisationAddressess.ToSelectListItems(selectedId);
|
||||
}
|
||||
|
||||
public static List<SelectListItem> ToSelectListItems(this IEnumerable<OrganisationAddress> organisationAddressess, int? SelectedId = null, bool IncludeInstructionFirst = false, string InstructionMessage = "Select an Address")
|
||||
{
|
||||
var selectItems = default(List<SelectListItem>);
|
||||
if (!SelectedId.HasValue)
|
||||
selectItems = organisationAddressess.Select(wpd => new SelectListItem { Value = wpd.Id.Value.ToString(), Text = string.Format("{0} ({1})", wpd.Name, wpd.ShortName) }).ToList();
|
||||
else
|
||||
selectItems = organisationAddressess.Select(wpd => new SelectListItem { Value = wpd.Id.Value.ToString(), Text = string.Format("{0} ({1})", wpd.Name, wpd.ShortName), Selected = (SelectedId.Equals(wpd.Id)) }).ToList();
|
||||
|
||||
if (IncludeInstructionFirst)
|
||||
selectItems.Insert(0, new SelectListItem() { Value = String.Empty, Text = String.Format("<{0}>", InstructionMessage), Selected = !SelectedId.HasValue });
|
||||
|
||||
return selectItems;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Disco.Web.Extensions
|
||||
{
|
||||
public static class UtilityExtensions
|
||||
{
|
||||
public static string ToJavascriptDate(this DateTime d)
|
||||
{
|
||||
return string.Format("new Date({0}, {1}, {2}, {3}, {4}, {5})", d.Year, d.Month - 1, d.Day, d.Hour, d.Minute, d.Second);
|
||||
}
|
||||
public static string ToJavascriptDate(this DateTime? d, DateTime? DefaultDate = null)
|
||||
{
|
||||
if (d.HasValue)
|
||||
{
|
||||
return ToJavascriptDate(d.Value);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (DefaultDate.HasValue)
|
||||
return ToJavascriptDate(DefaultDate.Value);
|
||||
else
|
||||
return "null";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user