update
This commit is contained in:
@@ -10,4 +10,5 @@ public interface IItemRepository
|
||||
Item? GetByGlobal(Guid userId, Guid globalMotionId);
|
||||
bool Add(Item item);
|
||||
bool Update(Item item);
|
||||
List<Item> Find(Guid userId, string term, int limit);
|
||||
}
|
||||
@@ -31,7 +31,7 @@ public class ItemRepository : AppRepository<Item>, IItemRepository
|
||||
.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 == globalMotionId);
|
||||
}
|
||||
|
||||
public bool Update(Item item)
|
||||
@@ -43,4 +43,15 @@ public class ItemRepository : AppRepository<Item>, IItemRepository
|
||||
{
|
||||
return base.AddBase(item) > 0;
|
||||
}
|
||||
|
||||
public List<Item> Find(Guid userId, string term, int limit)
|
||||
{
|
||||
return _context
|
||||
.Items
|
||||
.Include(x => x.ItemGlobal)
|
||||
.Where(x => x.Category!.UserId == userId && x.ItemGlobal.Name.Contains(term))
|
||||
.OrderByDescending(x => x.Motions.Count())
|
||||
.Take(limit)
|
||||
.ToList();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user