This commit is contained in:
2023-06-17 14:16:09 +03:00
parent 62178f1f32
commit 7ae5d3bc81
180 changed files with 12932 additions and 192 deletions
@@ -0,0 +1,46 @@
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;
}
}