public bool Create(CryptocurrencyWallet item)
        {
            try
            {
                using var context = new OlavCryptoContext();

                context.WalletList.Attach(item.Wallet);
                context.CryptocurrencyList.Attach(item.Cryptocurrency);
                context.CryptocurrencyWalletList.Add(item);

                context.SaveChanges();

                var newItem = new CryptocurrencyDetails {
                    CryptocurrencyWallet = item
                };
                context.CryptocurrencyWalletList.Attach(newItem.CryptocurrencyWallet);
                context.CryptocurrencyDetailsList.Add(newItem);

                context.SaveChanges();

                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
        public IActionResult CreateCryprocurrency(CryptocurrencyDetails cryptocurrencyDetails)
        {
            if (_cryptocurrencyDetailsService.CreateCryptocurrencyDetails(cryptocurrencyDetails))
            {
                return(Created(string.Empty, cryptocurrencyDetails));
            }

            return(BadRequest());
        }
 public IActionResult EditCryptocurrencyDetails(CryptocurrencyDetails cryptocurrencyDetails)
 {
     if (_cryptocurrencyDetailsService.UpdateCryptocurrencyDetails(cryptocurrencyDetails))
     {
         return(Ok());
     }
     else
     {
         return(BadRequest());
     }
 }
 public bool UpdateCryptocurrencyDetails(CryptocurrencyDetails cryptocurrencyDetails)
 {
     return(_cryptocurrencyDetailsRepository.Update(cryptocurrencyDetails));
 }
Exemple #5
0
 public bool SaveCryptocurrenyDetails(CryptocurrencyDetails cryptocurrencyDetails)
 {
     return(_cryptocurrencyDetailsRepository.Create(cryptocurrencyDetails));
 }