Exemplo n.º 1
0
        public ActionResult ListCode(string text, int page, string code, AdwOrderType orderType, AdwDisplayType displayType, IEnumerable <string> excludeValues)
        {
            var result = Enumerable.Empty <SelectListItem>();

            if (!string.IsNullOrEmpty(code))
            {
                result = AdwService.GetListCodes(code).ToOrderedSelectListItem(orderType, displayType).Where(m => excludeValues == null || !excludeValues.Contains(m.Value));
            }

            return(AjaxSelectionView(text, page, result));
        }
Exemplo n.º 2
0
        /// <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);
        }
Exemplo n.º 3
0
 /// <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));
 }