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 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); } }
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); } }
public bool Create(Cryptocurrency item) { try { using var context = new OlavCryptoContext(); context.CryptocurrencyList.Add(item); context.SaveChangesAsync(); return(true); } catch (Exception) { return(false); } }
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()); }