refactoring
This commit is contained in:
@@ -1,24 +0,0 @@
|
||||
namespace MyOffice.Data.Repositories.Account;
|
||||
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Models.Accounts;
|
||||
|
||||
public class AccountMotionRepository : AppRepository<AccountMotion>, IAccountMotionRepository
|
||||
{
|
||||
public bool Add(AccountMotion accountMotion)
|
||||
{
|
||||
return AddBase(accountMotion) > 0;
|
||||
}
|
||||
|
||||
public List<AccountMotion> GetByAccount(Guid accountId, DateTime dateFrom, DateTime dateTo)
|
||||
{
|
||||
return _context
|
||||
.AccountMotions
|
||||
.Include(x => x.Motion)
|
||||
.ThenInclude(x => x.MotionGlobal)
|
||||
.Where(x => x.AccountId == accountId && x.DateTime >= dateFrom && x.DateTime <= dateTo)
|
||||
.OrderByDescending(x => x.DateTime)
|
||||
.ThenByDescending(x => x.CreatedOn)
|
||||
.ToList();
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
namespace MyOffice.Data.Repositories.Account;
|
||||
|
||||
using Models.Accounts;
|
||||
|
||||
public interface IAccountMotionRepository
|
||||
{
|
||||
bool Add(AccountMotion accountMotion);
|
||||
List<AccountMotion> GetByAccount(Guid accountId, DateTime dateFrom, DateTime dateTo);
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
namespace MyOffice.Data.Repositories.Account;
|
||||
|
||||
using Models.Accounts;
|
||||
|
||||
public interface IMotionRepository
|
||||
{
|
||||
bool Add(Motion motion);
|
||||
List<Motion> GetByAccount(Guid accountId, DateTime dateFrom, DateTime dateTo);
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
namespace MyOffice.Data.Repositories.Account;
|
||||
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Models.Accounts;
|
||||
|
||||
public class MotionRepository : AppRepository<Motion>, IMotionRepository
|
||||
{
|
||||
public bool Add(Motion motion)
|
||||
{
|
||||
return AddBase(motion) > 0;
|
||||
}
|
||||
|
||||
public List<Motion> GetByAccount(Guid accountId, DateTime dateFrom, DateTime dateTo)
|
||||
{
|
||||
return _context
|
||||
.Motions
|
||||
.Include(x => x.Item)
|
||||
.ThenInclude(x => x.ItemGlobal)
|
||||
.Where(x => x.AccountId == accountId && x.DateTime >= dateFrom && x.DateTime <= dateTo)
|
||||
.OrderByDescending(x => x.DateTime)
|
||||
.ThenByDescending(x => x.CreatedOn)
|
||||
.ToList();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user