fix
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
namespace MyOffice.Data.Repositories.Currency;
|
||||
|
||||
using Models.Currencies;
|
||||
|
||||
public class CurrencyGlobalRepository : AppRepository<CurrencyGlobal>, ICurrencyGlobalRepository
|
||||
{
|
||||
public List<CurrencyGlobal> GetAll()
|
||||
{
|
||||
return _context.CurrencyGlobals.ToList();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
namespace MyOffice.Data.Repositories.Currency;
|
||||
|
||||
using Models.Currencies;
|
||||
|
||||
public class CurrencyRateRepository : AppRepository<CurrencyRate>, ICurrencyRateRepository
|
||||
{
|
||||
public List<CurrencyRate> GetLastRates(Guid currencyId, int count = 1)
|
||||
{
|
||||
return _context.CurrencyRates
|
||||
.Where(x => x.CurrencyId == currencyId)
|
||||
.OrderByDescending(x => x.DateTime)
|
||||
.ThenByDescending(x => x.Id)
|
||||
.Take(count)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public bool AddRate(CurrencyRate currencyRate)
|
||||
{
|
||||
return this.AddBase(currencyRate) > 0;
|
||||
}
|
||||
|
||||
public List<CurrencyRate> GetAtDate(Guid currencyId, DateTime date)
|
||||
{
|
||||
return _context.CurrencyRates
|
||||
.Where(x => x.CurrencyId == currencyId && x.DateTime == date)
|
||||
.ToList();
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
namespace MyOffice.Data.Repositories.Currency;
|
||||
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Models.Currencies;
|
||||
using MyOffice.Data.Repositories;
|
||||
|
||||
public class CurrencyRepository : AppRepository<Currency>, ICurrencyRepository
|
||||
{
|
||||
public List<Currency> GetAll(Guid userId)
|
||||
{
|
||||
return _context.Currencies
|
||||
.Include(x => x.CurrencyGlobal)
|
||||
.Where(x => x.UserId == userId)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public Currency? Get(Guid userId, Guid id)
|
||||
{
|
||||
return _context.Currencies.FirstOrDefault(x => x.Id == id && x.UserId == userId);
|
||||
}
|
||||
|
||||
public Currency? GetByGlobalCurrency(Guid userId, string globalCurrencyId)
|
||||
{
|
||||
return _context.Currencies.FirstOrDefault(x => x.UserId == userId && x.CurrencyGlobalId == globalCurrencyId);
|
||||
}
|
||||
|
||||
public bool Add(Currency currency)
|
||||
{
|
||||
return AddBase(currency) > 0;
|
||||
}
|
||||
|
||||
public bool Update(Currency currency)
|
||||
{
|
||||
return UpdateBase(currency) > 0;
|
||||
}
|
||||
|
||||
public bool Remove(Currency currency)
|
||||
{
|
||||
return RemoveBase(currency) > 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace MyOffice.Data.Repositories.Currency;
|
||||
|
||||
using Models.Currencies;
|
||||
|
||||
public interface ICurrencyGlobalRepository
|
||||
{
|
||||
List<CurrencyGlobal> GetAll();
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
namespace MyOffice.Data.Repositories.Currency;
|
||||
|
||||
using Models.Currencies;
|
||||
|
||||
public interface ICurrencyRateRepository
|
||||
{
|
||||
List<CurrencyRate> GetLastRates(Guid currencyId, int count = 1);
|
||||
bool AddRate(CurrencyRate currencyRate);
|
||||
List<CurrencyRate> GetAtDate(Guid currencyId, DateTime date);
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
namespace MyOffice.Data.Repositories.Currency;
|
||||
|
||||
using Models.Currencies;
|
||||
|
||||
public interface ICurrencyRepository
|
||||
{
|
||||
List<Currency> GetAll(Guid userId);
|
||||
Currency? Get(Guid userId, Guid id);
|
||||
Currency? GetByGlobalCurrency(Guid userId, string globalCurrencyId);
|
||||
bool Add(Currency currency);
|
||||
bool Update(Currency currency);
|
||||
bool Remove(Currency currency);
|
||||
}
|
||||
Reference in New Issue
Block a user