| | |
| | | { |
| | | return await (await GetDbSetAsync()) |
| | | .IncludeDetails() |
| | | .Where(x => !x.IsDeleted) |
| | | .OrderBy(t => t.Sort) |
| | | .FirstOrDefaultAsync(t => t.StoreCode == name, GetCancellationToken(cancellationToken)); |
| | | } |
| | |
| | | /// <inheritdoc /> |
| | | public async Task<bool> NameExistAsync(string storeCode, Guid? id = null) |
| | | { |
| | | return await (await GetDbSetAsync()).WhereIf(id.HasValue, p => p.Id != id).AnyAsync(x => x.StoreCode == storeCode); |
| | | return await (await GetDbSetAsync()).WhereIf(id.HasValue, p => p.Id != id).Where(x => !x.IsDeleted).AnyAsync(x => x.StoreCode == storeCode); |
| | | } |
| | | |
| | | /// <inheritdoc /> |
| | | public async Task<int> GetMaxSortAsync() |
| | | { |
| | | var hasAny = await (await GetQueryableAsync()).AnyAsync(); |
| | | var hasAny = await (await GetQueryableAsync()) |
| | | .Where(x => !x.IsDeleted).AnyAsync(); |
| | | if (!hasAny) |
| | | { |
| | | return 1; |
| | | } |
| | | |
| | | var sort = await (await GetQueryableAsync()).MaxAsync(x => x.Sort); |
| | | var sort = await (await GetQueryableAsync()) |
| | | .Where(x => !x.IsDeleted).MaxAsync(x => x.Sort); |
| | | return sort + 1; |
| | | } |
| | | |
| | |
| | | return await (await GetDbSetAsync()) |
| | | .IncludeDetails(includeDetails) |
| | | .Where(specification.ToExpression()) |
| | | .Where(x => !x.IsDeleted) |
| | | .WhereIf(!filter.IsNullOrWhiteSpace(), u => u.StoreCode.Contains(filter)) |
| | | .OrderBy(sorting.IsNullOrEmpty() ? nameof(WmsStore.Sort) : sorting) |
| | | .PageBy(skipCount, maxResultCount) |
| | |
| | | specification ??= new WmsStoreSpecification(); |
| | | return await (await GetQueryableAsync()) |
| | | .Where(specification.ToExpression()) |
| | | .Where(x => !x.IsDeleted) |
| | | .WhereIf(!filter.IsNullOrWhiteSpace(), u => u.StoreCode.Contains(filter)) |
| | | .CountAsync(cancellationToken: GetCancellationToken(cancellationToken)); |
| | | } |
| | |
| | | /// <inheritdoc /> |
| | | public override async Task<IQueryable<WmsStore>> WithDetailsAsync() |
| | | { |
| | | return (await GetQueryableAsync()).IncludeDetails(); |
| | | return (await GetQueryableAsync()) |
| | | .Where(x => !x.IsDeleted).IncludeDetails(); |
| | | } |
| | | } |