public static async Task <ResultsItem> DeleteUserCoinsAsync(List <CryptoCoin> coins, PegaUser user) { if (coins.Any(x => !IsValidDBRequest(user, x.PortfolioId, validatePortfolio: true).IsSuccess)) { return(ResultsItem.Error(Lang.PortfolioNotFound)); } return(await CryptoRepository.DeleteUserCoinAsync(coins)); }
public static ResultsPair <Portfolio> UpdatePortfolio(int portfolioId, string portfolioName, Types.PortfolioDisplayType displayType, bool isDefault, PegaUser user) { if (!IsValidDBRequest(user, portfolioId, validatePortfolio: true).IsSuccess) { return(ResultsPair.CreateError <Portfolio>(Lang.PortfolioNotFound)); } return(CryptoRepository.UpdatePortfolio(portfolioId, portfolioName, displayType, isDefault)); }
public CryptoControllerTest(ContextFixture contextFixture) { var cryptoRepository = new CryptoRepository(contextFixture.ApiContext); var cryptoService = new CryptoService(cryptoRepository); var coinMarketCapApiService = new CoinMarketCapApiService(cryptoRepository, contextFixture.Configuration); _cryptoController = new CryptoController(cryptoService, coinMarketCapApiService); }
public WalletControllerTest(ContextFixture contextFixture) { var walletRepository = new WalletRepository(contextFixture.ApiContext); var cryptoRepository = new CryptoRepository(contextFixture.ApiContext); var emailEmailService = new EmailService(); var coinMarketCapApiService = new WalletOperationsService(emailEmailService); _walletController = new WalletController(walletRepository, cryptoRepository, coinMarketCapApiService); }
public static ResultsItem DeleteAPI(int apiId, PegaUser user) { var validateRequest = IsValidDBRequest(user, apiId, validateAPI: true); if (!validateRequest.IsSuccess) { return(validateRequest); } return(CryptoRepository.DeleteAPI(apiId)); }
public static async Task <ResultsPair <Portfolio> > InsertNewPortfolio(PegaUser user, string portfolioName, Types.PortfolioDisplayType displayType, bool isDefault) { var validateRequest = IsValidDBRequest(user, 0); if (!validateRequest.IsSuccess) { return(ResultsPair.CreateError <Portfolio>(validateRequest.Message)); } return(await CryptoRepository.InsertNewPortfolio(user.UserId, portfolioName, displayType, isDefault)); }
public static async Task <ResultsItem> UpdateUserCoinAsync(CryptoCoin coin, PegaUser user) { var validateRequest = IsValidDBRequest(user, coin.PortfolioId, validatePortfolio: true); if (!validateRequest.IsSuccess) { return(validateRequest); } return(await CryptoRepository.UpdateUserCoinAsync(coin)); }
public static ResultsItem InsertNewAPI(ExchangeApiInfo exchangeApiInfo, PegaUser user) { var validateRequest = IsValidDBRequest(user, 0); if (!validateRequest.IsSuccess) { return(validateRequest); } return(CryptoRepository.InsertNewAPI(exchangeApiInfo, user)); }
public static async Task <ResultsItem> DeleteAllUserCoinByExchangeAsync(int portfolioId, Types.Exchanges exchange, PegaUser user) { var validateRequest = IsValidDBRequest(user, portfolioId, validatePortfolio: true); if (!validateRequest.IsSuccess) { return(validateRequest); } return(await CryptoRepository.DeleteAllUserCoinByExchangeAsync(portfolioId, exchange)); }
public static async Task <ResultsItem> DeletePortfolio(int portfolioId, PegaUser user) { var validateRequest = IsValidDBRequest(user, portfolioId, validatePortfolio: true); if (!validateRequest.IsSuccess) { return(validateRequest); } ResultsItem deleteResult = await CryptoRepository.DeletePortfolio(portfolioId); // Since we're deleting the only portfolio we have, create a new default one. if (user.Portfolios.Count == 1) { await InsertNewPortfolio(user, "Default", Types.PortfolioDisplayType.Private, true); } return(deleteResult); }
public static async Task <ResultsItem> InsertCoinsToUserPortfolioAsync(List <CryptoCoin> coins, PegaUser user, int?portfolioId = null) { // Validation: Do not allow symbol to end in -USD. if (coins.Any(x => x.Symbol.ToUpperInvariant().Contains("-USD"))) { if (coins.Count == 1) { return(ResultsItem.Error("The coin symbol must not end in -USD. It should be USD-. For example: USD-ETH, USD-XRP.")); } coins = coins.Where(x => !x.Symbol.ToUpperInvariant().Contains("-USD")).ToList(); } if (portfolioId != null) { coins.ForEach(x => x.PortfolioId = portfolioId.Value); } if (coins.Any(x => !IsValidDBRequest(user, x.PortfolioId, validatePortfolio: true).IsSuccess)) { return(ResultsItem.Error(Lang.PortfolioNotFound)); } return(await CryptoRepository.InsertCoinsToUserPortfolioAsync(coins)); }
public static async Task <List <CryptoCoin> > GetAllUserCoinsByPortfolioIdAsync(int portfolioId) { // Make sure controller has !user.HasPortfolio check return(await CryptoRepository.GetAllUserCoinsByPortfolioIdAsync(portfolioId)); }
public static async Task <CryptoCoin> GetSingleCoinByUser(long coinId, PegaUser user) { CryptoCoin coin = await CryptoRepository.GetSingleCoinByUser(coinId); return(!IsValidDBRequest(user, coin.PortfolioId, validatePortfolio: true, validateDemoUser: false).IsSuccess ? null : coin); }
public static async Task <List <Portfolio> > GetAllUserPortfolioAsync(PegaUser user) { return(await CryptoRepository.GetAllUserPortfolioAsync(user)); }
public CoinMarketCapApiServiceTest(ContextFixture contextFixture) { var cryptoRepository = new CryptoRepository(contextFixture.ApiContext); _coinMarketCapApiService = new CoinMarketCapApiService(cryptoRepository, contextFixture.Configuration); }
public static async Task <List <ExchangeApiInfo> > GetAllUserExchangeAPIAsync(int userId) { return(await CryptoRepository.GetAllUserExchangeAPIAsync(userId)); }
public static List <OfficialCoin> GetAllOfficialCoins() => CryptoRepository.GetAllOfficialCoins();
public static async Task <ResultsPair <Portfolio> > ResetAllUserTrades(PegaUser user) { return(await CryptoRepository.ResetAllUserTrades(user)); }