Files
myoffice/MyOffice.Data.Repositories/Currency/CurrencyRepository.cs
T
2023-06-21 17:56:00 +03:00

44 lines
1002 B
C#

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
.Include(x => x.CurrencyGlobal)
.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;
}
}