This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ExcelFileResult<T> : ActionResult | |
{ | |
private readonly IEnumerable<T> _records; | |
public ExcelFileResult(IEnumerable<T> records) | |
{ | |
_records = records; | |
} | |
public override void ExecuteResult(ControllerContext context) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ExcelColumnDefinition | |
{ | |
public MemberInfo MemberInfo { get; set; } | |
public string Format { get; set; } | |
public string Header { get; set; } | |
public static ExcelColumnDefinition Create<T>(Expression<Func<T, object>> member, string format = null, string header = null) | |
{ | |
return new ExcelColumnDefinition { MemberInfo = GetMemberInfo(member), Format = format, Header = header }; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public ActionResult ExportToExcel() | |
{ | |
var records = _getSampleInfoQuery.Execute(); | |
var columns = new[] | |
{ | |
Column(x => x.College), | |
Column(x => x.Amount, ExcelFormat.Money), | |
Column(x => x.CreatedDate, ExcelFormat.Date, "Date"), | |
Column(x => x.CreatedBy), | |
Column(x => x.CreatedDate, ExcelFormat.Time, "Time"), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static ExcelColumnDefinition Column(Expression<Func<SampleInfo, object>> member, string format = null, string header = null) | |
{ | |
return ExcelColumnDefinition.Create(member, format, header); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public ActionResult ExportToExcel() | |
{ | |
var records = _getSampleInfoQuery.Execute(); | |
var columns = new[] | |
{ | |
ExcelColumnDefinition.Create<SampleInfo>(x => x.College), | |
ExcelColumnDefinition.Create<SampleInfo>(x => x.Amount, ExcelFormat.Money), | |
ExcelColumnDefinition.Create<SampleInfo>(x => x.CreatedDate, ExcelFormat.Date, "Date"), | |
ExcelColumnDefinition.Create<SampleInfo>(x => x.CreatedBy), | |
ExcelColumnDefinition.Create<SampleInfo>(x => x.CreatedDate, ExcelFormat.Time, "Time"), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public ActionResult ExportToExcel() | |
{ | |
var records = _getSampleInfoQuery.Execute(); | |
return new ExcelFileResult<SampleInfo>(records); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<style type="text/css"> | |
.toggle-me { display: none; } | |
div:hover .toggle-me { display: inline-block; } | |
</style> | |
<body> | |
<div>Most Important <span class="toggle-me">More Information</span></div> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static MvcHtmlString DropDownListFor<TModel, TProperty>(this HtmlHelper<TModel> html, Expression<Func<TModel, TProperty>> expression) where TModel : class | |
{ | |
var property = expression.GetProperty(); | |
IEnumerable<SelectListItem> selectList; | |
var selectListProviderAttribute = property.GetAttribute<SelectListProviderAttribute>(); | |
if (selectListProviderAttribute != null) | |
{ | |
var provider = selectListProviderAttribute.Provider; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class CommunitySelectListProvider : ISelectListProvider | |
{ | |
private readonly IGetCommunitiesQuery _getCommunitiesQuery; | |
public CommunitySelectListProvider(IGetCommunitiesQuery getCommunitiesQuery) | |
{ | |
_getCommunitiesQuery = getCommunitiesQuery; | |
} | |
public IEnumerable<SelectListItem> Provide() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface ISelectListProvider | |
{ | |
IEnumerable<SelectListItem> Provide(); | |
} |
NewerOlder