fix
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
namespace MyOffice.Data.Repositories.Item;
|
||||
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using MyOffice.Data.Models.Items;
|
||||
|
||||
public class ItemGlobalRepository : AppRepository<ItemGlobal>, IItemGlobalRepository
|
||||
@@ -18,4 +19,19 @@ public class ItemGlobalRepository : AppRepository<ItemGlobal>, IItemGlobalReposi
|
||||
{
|
||||
return AddBase(itemGlobal) > 0;
|
||||
}
|
||||
|
||||
public List<ItemGlobal> GetAvailableToUser(Guid userId)
|
||||
{
|
||||
return _context.Motions
|
||||
.Include(x => x.Item)
|
||||
.ThenInclude(x => x.ItemGlobal)
|
||||
.ThenInclude(x => x.Items)
|
||||
.ThenInclude(x => x.Category)
|
||||
.Where(x => x.Account.AccessRights!.Any(a => a.UserId == userId))
|
||||
.Where(x => x.Item.ItemGlobal.Items.All(g => g.Category!.UserId != userId))
|
||||
.Select(x => x.Item.ItemGlobal)
|
||||
.GroupBy(x => x.Id)
|
||||
.Select(x => x.First())
|
||||
.ToList();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user