public ValueListEditAdminViewModel(StoreFront storeFront, UserProfile userProfile, ValueList valueList, string activeTab, bool isStoreAdminEdit = false, bool isReadOnly = false, bool isDeletePage = false, bool isCreatePage = false, string sortBy = "", bool?sortAscending = true)
 {
     if (storeFront == null)
     {
         throw new ArgumentNullException("storeFront");
     }
     if (userProfile == null)
     {
         throw new ArgumentNullException("userProfile");
     }
     if (valueList == null)
     {
         throw new ArgumentNullException("valueList", "valueList cannot be null");
     }
     this.IsStoreAdminEdit = isStoreAdminEdit;
     this.IsActiveDirect   = valueList.IsActiveDirect();
     this.IsActiveBubble   = valueList.IsActiveBubble();
     this.IsReadOnly       = isReadOnly;
     this.IsDeletePage     = isDeletePage;
     this.IsCreatePage     = isCreatePage;
     this.ActiveTab        = activeTab;
     this.SortBy           = sortBy;
     this.SortAscending    = sortAscending;
     LoadValues(storeFront, userProfile, valueList);
 }
Esempio n. 2
0
        /// <summary>
        /// Returns a Select List for MVC. Return type is IEnumerable SelectListItem
        /// returns active records only
        /// </summary>
        /// <param name="pageTemplates"></param>
        /// <param name="selectedPageTemplateId"></param>
        /// <returns></returns>
        public static List <SelectListItem> ToSelectList(this ValueList valueList, int?selectedValueListItemId)
        {
            if (!valueList.IsActiveBubble())
            {
                return(new List <SelectListItem>());
            }

            IOrderedQueryable <ValueListItem> orderedListItems = valueList.ValueListItems.AsQueryable().WhereIsActive().ApplyDefaultSort();

            int valueListItemId = selectedValueListItemId ?? 0;

            List <SelectListItem> items = orderedListItems.Select(vl => new SelectListItem
            {
                Value    = vl.ValueListItemId.ToString(),
                Text     = (vl.ValueListItemId == valueListItemId ? "[SELECTED] " : string.Empty) + vl.Name,
                Selected = vl.ValueListItemId == valueListItemId
            }).ToList();

            return(items);
        }