Add initial project structure with basic view models, views, and resources
This commit is contained in:
@@ -0,0 +1,214 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using CryptoPortfolio_Tracker.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace CryptoPortfolio_Tracker.Context;
|
||||
|
||||
public partial class CryptoContext : DbContext
|
||||
{
|
||||
public CryptoContext()
|
||||
{
|
||||
}
|
||||
|
||||
public CryptoContext(DbContextOptions<CryptoContext> options)
|
||||
: base(options)
|
||||
{
|
||||
}
|
||||
|
||||
public virtual DbSet<CryptoType> CryptoTypes { get; set; }
|
||||
|
||||
public virtual DbSet<Cryptocurrency> Cryptocurrencies { get; set; }
|
||||
|
||||
public virtual DbSet<Network> Networks { get; set; }
|
||||
|
||||
public virtual DbSet<Transaction> Transactions { get; set; }
|
||||
|
||||
public virtual DbSet<TransactionType> TransactionTypes { get; set; }
|
||||
|
||||
public virtual DbSet<TransactionsStatus> TransactionsStatuses { get; set; }
|
||||
|
||||
public virtual DbSet<User> Users { get; set; }
|
||||
|
||||
public virtual DbSet<UserWallet> UserWallets { get; set; }
|
||||
|
||||
public virtual DbSet<WalletType> WalletTypes { get; set; }
|
||||
|
||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||
#warning To protect potentially sensitive information in your connection string, you should move it out of source code. You can avoid scaffolding the connection string by using the Name= syntax to read it from configuration - see https://go.microsoft.com/fwlink/?linkid=2131148. For more guidance on storing connection strings, see https://go.microsoft.com/fwlink/?LinkId=723263.
|
||||
=> optionsBuilder.UseNpgsql("Host=denjir-host.ru;Database=crypto;Username=crypto;Password=crypto;");
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
modelBuilder.Entity<CryptoType>(entity =>
|
||||
{
|
||||
entity.HasKey(e => e.Id).HasName("crypto_types_pkey");
|
||||
|
||||
entity.ToTable("crypto_types");
|
||||
|
||||
entity.Property(e => e.Id).HasColumnName("id");
|
||||
entity.Property(e => e.Name).HasColumnName("name");
|
||||
});
|
||||
|
||||
modelBuilder.Entity<Cryptocurrency>(entity =>
|
||||
{
|
||||
entity.HasKey(e => e.Id).HasName("cryptocurrencies_pkey");
|
||||
|
||||
entity.ToTable("cryptocurrencies");
|
||||
|
||||
entity.HasIndex(e => e.CoingeckoId, "cryptocurrencies_coingecko_id_key").IsUnique();
|
||||
|
||||
entity.HasIndex(e => e.Symbol, "cryptocurrencies_symbol_key").IsUnique();
|
||||
|
||||
entity.Property(e => e.Id).HasColumnName("id");
|
||||
entity.Property(e => e.CoingeckoId).HasColumnName("coingecko_id");
|
||||
entity.Property(e => e.CryptoTypeId).HasColumnName("crypto_type_id");
|
||||
entity.Property(e => e.Name).HasColumnName("name");
|
||||
entity.Property(e => e.NetworkId).HasColumnName("network_id");
|
||||
entity.Property(e => e.Symbol).HasColumnName("symbol");
|
||||
|
||||
entity.HasOne(d => d.CryptoType).WithMany(p => p.Cryptocurrencies)
|
||||
.HasForeignKey(d => d.CryptoTypeId)
|
||||
.HasConstraintName("cryptocurrencies_crypto_type_id_fkey");
|
||||
|
||||
entity.HasOne(d => d.Network).WithMany(p => p.Cryptocurrencies)
|
||||
.HasForeignKey(d => d.NetworkId)
|
||||
.HasConstraintName("cryptocurrencies_networks_fk");
|
||||
});
|
||||
|
||||
modelBuilder.Entity<Network>(entity =>
|
||||
{
|
||||
entity.HasKey(e => e.Id).HasName("networks_pk");
|
||||
|
||||
entity.ToTable("networks");
|
||||
|
||||
entity.Property(e => e.Id).HasColumnName("id");
|
||||
entity.Property(e => e.Name).HasColumnName("name");
|
||||
});
|
||||
|
||||
modelBuilder.Entity<Transaction>(entity =>
|
||||
{
|
||||
entity.HasKey(e => e.Id).HasName("transactions_pkey");
|
||||
|
||||
entity.ToTable("transactions");
|
||||
|
||||
entity.Property(e => e.Id).HasColumnName("id");
|
||||
entity.Property(e => e.Amount)
|
||||
.HasPrecision(30, 18)
|
||||
.HasColumnName("amount");
|
||||
entity.Property(e => e.CryptocurrencyId).HasColumnName("cryptocurrency_id");
|
||||
entity.Property(e => e.FeeUsd)
|
||||
.HasPrecision(30, 2)
|
||||
.HasColumnName("fee_usd");
|
||||
entity.Property(e => e.PriceUsd)
|
||||
.HasPrecision(24, 10)
|
||||
.HasColumnName("price_usd");
|
||||
entity.Property(e => e.RecipientAddress).HasColumnName("recipient_address");
|
||||
entity.Property(e => e.SenderAddress).HasColumnName("sender_address");
|
||||
entity.Property(e => e.StatusId).HasColumnName("status_id");
|
||||
entity.Property(e => e.TotalUsd)
|
||||
.HasPrecision(30, 2)
|
||||
.HasColumnName("total_usd");
|
||||
entity.Property(e => e.TransactionDate)
|
||||
.HasDefaultValueSql("now()")
|
||||
.HasColumnName("transaction_date");
|
||||
entity.Property(e => e.TransactionHash).HasColumnName("transaction_hash");
|
||||
entity.Property(e => e.TransactionTypeId).HasColumnName("transaction_type_id");
|
||||
entity.Property(e => e.WalletId).HasColumnName("wallet_id");
|
||||
|
||||
entity.HasOne(d => d.Cryptocurrency).WithMany(p => p.Transactions)
|
||||
.HasForeignKey(d => d.CryptocurrencyId)
|
||||
.HasConstraintName("transactions_cryptocurrency_id_fkey");
|
||||
|
||||
entity.HasOne(d => d.Status).WithMany(p => p.Transactions)
|
||||
.HasForeignKey(d => d.StatusId)
|
||||
.HasConstraintName("transactions_status_id_fkey");
|
||||
|
||||
entity.HasOne(d => d.TransactionType).WithMany(p => p.Transactions)
|
||||
.HasForeignKey(d => d.TransactionTypeId)
|
||||
.HasConstraintName("transactions_transaction_type_id_fkey");
|
||||
|
||||
entity.HasOne(d => d.Wallet).WithMany(p => p.Transactions)
|
||||
.HasForeignKey(d => d.WalletId)
|
||||
.HasConstraintName("transactions_wallet_id_fkey");
|
||||
});
|
||||
|
||||
modelBuilder.Entity<TransactionType>(entity =>
|
||||
{
|
||||
entity.HasKey(e => e.Id).HasName("transaction_types_pkey");
|
||||
|
||||
entity.ToTable("transaction_types");
|
||||
|
||||
entity.Property(e => e.Id).HasColumnName("id");
|
||||
entity.Property(e => e.Name).HasColumnName("name");
|
||||
});
|
||||
|
||||
modelBuilder.Entity<TransactionsStatus>(entity =>
|
||||
{
|
||||
entity.HasKey(e => e.Id).HasName("transactions_statuses_pkey");
|
||||
|
||||
entity.ToTable("transactions_statuses");
|
||||
|
||||
entity.Property(e => e.Id).HasColumnName("id");
|
||||
entity.Property(e => e.Name).HasColumnName("name");
|
||||
});
|
||||
|
||||
modelBuilder.Entity<User>(entity =>
|
||||
{
|
||||
entity.HasKey(e => e.Id).HasName("users_pkey");
|
||||
|
||||
entity.ToTable("users");
|
||||
|
||||
entity.Property(e => e.Id).HasColumnName("id");
|
||||
entity.Property(e => e.Email).HasColumnName("email");
|
||||
entity.Property(e => e.Login).HasColumnName("login");
|
||||
entity.Property(e => e.Password).HasColumnName("password");
|
||||
});
|
||||
|
||||
modelBuilder.Entity<UserWallet>(entity =>
|
||||
{
|
||||
entity.HasKey(e => e.Id).HasName("user_wallets_pkey");
|
||||
|
||||
entity.ToTable("user_wallets");
|
||||
|
||||
entity.HasIndex(e => e.Address, "user_wallets_address_key").IsUnique();
|
||||
|
||||
entity.Property(e => e.Id).HasColumnName("id");
|
||||
entity.Property(e => e.Address).HasColumnName("address");
|
||||
entity.Property(e => e.Amount)
|
||||
.HasPrecision(30, 12)
|
||||
.HasColumnName("amount");
|
||||
entity.Property(e => e.CryptocurrencyId).HasColumnName("cryptocurrency_id");
|
||||
entity.Property(e => e.Name).HasColumnName("name");
|
||||
entity.Property(e => e.TypeId).HasColumnName("type_id");
|
||||
entity.Property(e => e.UserId).HasColumnName("user_id");
|
||||
|
||||
entity.HasOne(d => d.Cryptocurrency).WithMany(p => p.UserWallets)
|
||||
.HasForeignKey(d => d.CryptocurrencyId)
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.HasConstraintName("user_wallets_cryptocurrencies_fk");
|
||||
|
||||
entity.HasOne(d => d.Type).WithMany(p => p.UserWallets)
|
||||
.HasForeignKey(d => d.TypeId)
|
||||
.HasConstraintName("user_wallets_type_id_fkey");
|
||||
|
||||
entity.HasOne(d => d.User).WithMany(p => p.UserWallets)
|
||||
.HasForeignKey(d => d.UserId)
|
||||
.HasConstraintName("user_wallets_user_id_fkey");
|
||||
});
|
||||
|
||||
modelBuilder.Entity<WalletType>(entity =>
|
||||
{
|
||||
entity.HasKey(e => e.Id).HasName("wallet_types_pkey");
|
||||
|
||||
entity.ToTable("wallet_types");
|
||||
|
||||
entity.Property(e => e.Id).HasColumnName("id");
|
||||
entity.Property(e => e.Name).HasColumnName("name");
|
||||
});
|
||||
|
||||
OnModelCreatingPartial(modelBuilder);
|
||||
}
|
||||
|
||||
partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
|
||||
}
|
||||
Reference in New Issue
Block a user