refactoring
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user