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);
            }
        }
Exemple #2
0
 public bool Delete(int id)
 {
     try
     {
         using var context = new OlavCryptoContext();
         context.CryptocurrencyList.Remove(context.CryptocurrencyList.Find(id));
         context.SaveChanges();
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
Exemple #3
0
 public bool Update(Cryptocurrency item)
 {
     try
     {
         using var context = new OlavCryptoContext();
         context.CryptocurrencyList.Attach(item);
         context.Entry(item).State = EntityState.Modified;
         context.SaveChanges();
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
Exemple #4
0
        public bool Create(Cryptocurrency item)
        {
            try
            {
                using var context = new OlavCryptoContext();
                context.CryptocurrencyList.Add(item);
                context.SaveChangesAsync();

                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
Exemple #5
0
 public IList <Cryptocurrency> Get()
 {
     using var context = new OlavCryptoContext();
     return(context.CryptocurrencyList.ToList());
 }
 public IList <CryptocurrencyWallet> Get()
 {
     using var context = new OlavCryptoContext();
     return(context.CryptocurrencyWalletList.Include(x => x.Cryptocurrency).Include(x => x.Wallet).ToList());
 }
 public IList <Wallet> Get()
 {
     using var context = new OlavCryptoContext();
     return(context.WalletList.ToList());
 }