37 lines
820 B
C#
37 lines
820 B
C#
namespace MyOffice.Data.Repositories.Item;
|
|
|
|
using Microsoft.EntityFrameworkCore;
|
|
using MyOffice.Data.Models.Items;
|
|
|
|
public class ItemCategoryRepository : AppRepository<ItemCategory>, IItemCategoryRepository
|
|
{
|
|
public List<ItemCategory> GetAll(Guid userId)
|
|
{
|
|
return _context.ItemCategories
|
|
.Include(x => x.Items)
|
|
.Where(x => x.UserId == userId)
|
|
.ToList();
|
|
}
|
|
|
|
public bool Add(ItemCategory itemCategory)
|
|
{
|
|
return AddBase(itemCategory) > 0;
|
|
}
|
|
|
|
public ItemCategory? Get(Guid userId, Guid id)
|
|
{
|
|
return _context.ItemCategories
|
|
.Include(x => x.Items)
|
|
.FirstOrDefault(x => x.Id == id && x.UserId == userId);
|
|
}
|
|
|
|
public bool Update(ItemCategory itemCategory)
|
|
{
|
|
return UpdateBase(itemCategory) > 0;
|
|
}
|
|
|
|
public bool Remove(ItemCategory itemCategory)
|
|
{
|
|
return RemoveBase(itemCategory) > 0;
|
|
}
|
|
} |