46 lines
1.2 KiB
C#
46 lines
1.2 KiB
C#
namespace MyOffice.Data.Repositories.Motion;
|
|
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Models.Motions;
|
|
|
|
public class MotionRepository : AppRepository<MotionAccount>, IMotionRepository
|
|
{
|
|
public List<MotionAccount> GetAll(Guid userId)
|
|
{
|
|
return _context.Motions
|
|
.Include(x => x.Motions)
|
|
.Include(x => x.Category)
|
|
.Include(x => x.MotionGlobal)
|
|
.Where(x => x.Category.UserId == userId)
|
|
.ToList();
|
|
}
|
|
|
|
public List<MotionAccount> GetByCategory(Guid userId, Guid categoryId)
|
|
{
|
|
return _context.Motions
|
|
.Include(x => x.Motions)
|
|
.Include(x => x.Category)
|
|
.Include(x => x.MotionGlobal)
|
|
.Where(x => x.Category.UserId == userId && x.CategoryId == categoryId)
|
|
.ToList();
|
|
}
|
|
|
|
public MotionAccount? GetByGlobal(Guid userId, Guid globalMotionId)
|
|
{
|
|
return _context.Motions
|
|
.Include(x => x.Motions)
|
|
.Include(x => x.Category)
|
|
.Include(x => x.MotionGlobal)
|
|
.FirstOrDefault(x => x.Category.UserId == userId && x.MotionGlobalId == globalMotionId);
|
|
}
|
|
|
|
public bool Update(MotionAccount motionAccount)
|
|
{
|
|
return base.UpdateBase(motionAccount) > 0;
|
|
}
|
|
|
|
public bool Add(MotionAccount motionAccount)
|
|
{
|
|
return base.AddBase(motionAccount) > 0;
|
|
}
|
|
} |