Esempio n. 1
0
        /// <summary>
        /// 构造排序
        /// </summary>
        /// <param name="interfaceSortId"></param>
        /// <returns></returns>
        private SortDefinition <BsonDocument> StructureSortDefinition(Guid interfaceSortId)
        {
            var builder = new SortDefinitionBuilder <BsonDocument>();

            SortDefinition <BsonDocument> sort = null;

            if (interfaceSortId == Guid.Empty)
            {
                return(builder.Ascending("_id"));
            }

            var sorts = _interfaceSortRepository.GetInterfaceSortByParentId(interfaceSortId) ?? new List <InterfaceSort>(0);

            foreach (var item in sorts)
            {
                switch (item.GetSortType())
                {
                case SortTypeEnum.DESC:
                    sort = sort?.Descending(item.MetaFieldShortCode) ?? builder.Descending(item.MetaFieldShortCode);
                    break;

                case SortTypeEnum.ASC:
                    sort = sort?.Ascending(item.MetaFieldShortCode) ?? builder.Ascending(item.MetaFieldShortCode);
                    break;

                default:
                    break;
                }
            }

            return(sort);
        }
        public IActionResult SortItemList(Guid parentId)
        {
            var selectedFields = _interfaceSortRepository.GetInterfaceSortByParentId(parentId);

            ViewData["Id"] = parentId;

            return(View(selectedFields));
        }