fix
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
namespace MyOffice.Data.Repositories.Motion;
|
||||
|
||||
using Models.Motions;
|
||||
|
||||
public interface IMotionCategoryRepository
|
||||
{
|
||||
List<MotionCategory> GetAll(Guid userId);
|
||||
bool Add(MotionCategory accountCategory);
|
||||
MotionCategory? Get(Guid userId, Guid id);
|
||||
bool Update(MotionCategory accountCategory);
|
||||
bool Remove(MotionCategory accountCategory);
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
namespace MyOffice.Data.Repositories.Motion;
|
||||
|
||||
using Models.Motions;
|
||||
|
||||
public interface IMotionGlobalRepository
|
||||
{
|
||||
MotionGlobal? Get(Guid id);
|
||||
MotionGlobal? GetByName(string name);
|
||||
bool Add(MotionGlobal motionGlobal);
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
namespace MyOffice.Data.Repositories.Motion;
|
||||
|
||||
using Models.Motions;
|
||||
|
||||
public interface IMotionRepository
|
||||
{
|
||||
List<MotionAccount> GetAll(Guid userId);
|
||||
List<MotionAccount> GetByCategory(Guid userId, Guid categoryId);
|
||||
|
||||
MotionAccount? GetByGlobal(Guid userId, Guid globalMotionId);
|
||||
bool Add(MotionAccount motionAccount);
|
||||
bool Update(MotionAccount motionAccount);
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
namespace MyOffice.Data.Repositories.Motion;
|
||||
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Models.Motions;
|
||||
|
||||
public class MotionCategoryRepository : AppRepository<MotionCategory>, IMotionCategoryRepository
|
||||
{
|
||||
public List<MotionCategory> GetAll(Guid userId)
|
||||
{
|
||||
return _context.MotionCategories
|
||||
.Include(x => x.Motions)
|
||||
.Where(x => x.UserId == userId)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public bool Add(MotionCategory motionCategory)
|
||||
{
|
||||
return AddBase(motionCategory) > 0;
|
||||
}
|
||||
|
||||
public MotionCategory? Get(Guid userId, Guid id)
|
||||
{
|
||||
return _context.MotionCategories
|
||||
.Include(x => x.Motions)
|
||||
.FirstOrDefault(x => x.Id == id && x.UserId == userId);
|
||||
}
|
||||
|
||||
public bool Update(MotionCategory motionCategory)
|
||||
{
|
||||
return UpdateBase(motionCategory) > 0;
|
||||
}
|
||||
|
||||
public bool Remove(MotionCategory motionCategory)
|
||||
{
|
||||
return RemoveBase(motionCategory) > 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
namespace MyOffice.Data.Repositories.Motion;
|
||||
|
||||
using Models.Motions;
|
||||
|
||||
public class MotionGlobalRepository : AppRepository<MotionGlobal>, IMotionGlobalRepository
|
||||
{
|
||||
public MotionGlobal? Get(Guid id)
|
||||
{
|
||||
return _context.GlobalMotions.FirstOrDefault(x => x.Id == id);
|
||||
}
|
||||
|
||||
public MotionGlobal? GetByName(string name)
|
||||
{
|
||||
return _context.GlobalMotions.FirstOrDefault(x => x.Name == name);
|
||||
}
|
||||
|
||||
public bool Add(MotionGlobal motionGlobal)
|
||||
{
|
||||
return AddBase(motionGlobal) > 0;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user