예제 #1
0
        public async Task <List <MaterialGroup> > GetAllAsync(MaterialType type)
        {
            var groups = new List <MaterialGroup>
            {
                new MaterialGroup
                {
                    Id          = 0,
                    LibraryType = type,
                    GroupName   = "全部"
                }
            };

            var sites = await _siteRepository.GetSitesAsync();

            groups.AddRange(sites.Select(site => new MaterialGroup
            {
                Id          = -site.Id,
                LibraryType = type,
                GroupName   = site.SiteName
            }));

            var list = await _repository.GetAllAsync(Q
                                                     .Where(nameof(MaterialGroup.LibraryType), type.GetValue())
                                                     .OrderBy(nameof(MaterialGroup.Id))
                                                     .CachingGet(CacheKey(type))
                                                     );

            groups.AddRange(list);
            return(groups);
        }
        public async Task <bool> IsDeletable(MaterialType materialType, int materialId)
        {
            var count = await _repository.CountAsync(Q
                                                     .Where(nameof(MaterialMessageItem.MaterialType), materialType.GetValue())
                                                     .Where(nameof(MaterialMessageItem.MaterialId), materialId)
                                                     );

            return(count <= 1);
        }
예제 #3
0
 private string CacheKey(MaterialType type) => CacheUtils.GetListKey(TableName, type.GetValue());