fix
This commit is contained in:
@@ -7,4 +7,5 @@ public interface IItemGlobalRepository
|
||||
ItemGlobal? Get(Guid id);
|
||||
ItemGlobal? GetByName(string name);
|
||||
bool Add(ItemGlobal itemGlobal);
|
||||
List<ItemGlobal> GetAvailableToUser(Guid userId);
|
||||
}
|
||||
@@ -6,8 +6,7 @@ public interface IItemRepository
|
||||
{
|
||||
List<Item> GetAll(Guid userId);
|
||||
List<Item> GetByCategory(Guid userId, Guid categoryId);
|
||||
|
||||
Item? GetByGlobal(Guid userId, Guid globalMotionId);
|
||||
Item? GetByGlobal(Guid userId, Guid globalItemId);
|
||||
bool Add(Item item);
|
||||
bool Update(Item item);
|
||||
List<Item> Find(Guid userId, string term, int limit);
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
@@ -25,13 +25,13 @@ public class ItemRepository : AppRepository<Item>, IItemRepository
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public Item? GetByGlobal(Guid userId, Guid globalMotionId)
|
||||
public Item? GetByGlobal(Guid userId, Guid globalItemId)
|
||||
{
|
||||
return _context.Items
|
||||
.Include(x => x.Motions)
|
||||
.Include(x => x.Category)
|
||||
.Include(x => x.ItemGlobal)
|
||||
.FirstOrDefault(x => x.Category!.UserId == userId && x.ItemGlobalId == globalMotionId);
|
||||
.FirstOrDefault(x => x.Category!.UserId == userId && x.ItemGlobalId == globalItemId);
|
||||
}
|
||||
|
||||
public bool Update(Item item)
|
||||
|
||||
Reference in New Issue
Block a user