/// <summary> /// Returns text for the relevant <see cref="AdwDisplayType"/>. /// </summary> /// <returns>Text for the current instance using the specified <paramref name="displayType"/>.</returns> public string GetDisplayText(AdwDisplayType displayType) { string text = Description; switch (displayType) { case AdwDisplayType.Description: text = Description; break; case AdwDisplayType.ShortDescription: text = ShortDescription; break; case AdwDisplayType.Code: text = Code; break; case AdwDisplayType.CodeAndDescription: text = string.Format("{0} ({1})", Description, Code); break; case AdwDisplayType.CodeAndShortDescription: text = string.Format("{0} ({1})", ShortDescription, Code); break; } return(text); }
/// <summary> /// Converts a list of <see cref="CodeModel" /> to an enumerable of <see cref="SelectListItem" /> ordered by the specified <paramref name="orderType"/>. /// </summary> /// <param name="enumerable">The list of <see cref="CodeModel" />.</param> /// <param name="orderType">The order type to order by.</param> /// <param name="displayType">The display type to use for the display text.</param> /// <param name="selectedCodes">Any selected codes.</param> /// <returns>An enumerable of <see cref="SelectListItem" /> ordered by the specified <paramref name="orderType"/>.</returns> public static IEnumerable <SelectListItem> ToOrderedSelectListItem(this IList <CodeModel> enumerable, AdwOrderType orderType, AdwDisplayType displayType, object selectedCodes) { if (enumerable == null || !enumerable.Any()) { return(Enumerable.Empty <SelectListItem>()); } switch (orderType) { case AdwOrderType.ByDominantCode: case AdwOrderType.BySubordinateCode: case AdwOrderType.ByCode: enumerable = enumerable.OrderBy(m => m.Code).ToList(); break; } var result = enumerable.ToSelectListItem(m => m.Code, m => m.GetDisplayText(displayType), selectedCodes); if (orderType == AdwOrderType.ByDescription) { result = result.OrderBy(m => m.Text); } return(result); }
public ActionResult RelatedCode(string text, int page, string code, string dependentValue, bool dominant, AdwOrderType orderType, AdwDisplayType displayType, IEnumerable <string> excludeValues) { var result = Enumerable.Empty <SelectListItem>(); if (!string.IsNullOrEmpty(code)) { result = AdwService.GetRelatedCodes(code, dependentValue, dominant).ToOrderedSelectListItem(orderType, displayType).Where(m => excludeValues == null || !excludeValues.Contains(m.Value)); } return(AjaxSelectionView(text, page, result)); }
/// <summary> /// Converts a list of <see cref="CodeModel" /> to an enumerable of <see cref="SelectListItem" /> ordered by the specified <paramref name="orderType"/>. /// </summary> /// <param name="enumerable">The list of <see cref="CodeModel" />.</param> /// <param name="orderType">The order type to order by.</param> /// <param name="displayType">The display type to use for the display text.</param> /// <returns>An enumerable of <see cref="SelectListItem" /> ordered by the specified <paramref name="orderType"/>.</returns> public static IEnumerable <SelectListItem> ToOrderedSelectListItem(this IList <CodeModel> enumerable, AdwOrderType orderType, AdwDisplayType displayType) { return(ToOrderedSelectListItem(enumerable, orderType, displayType, null)); }