From a0b36633815d1d1f49597033c2be7f4ec14dae46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9D=D0=B8=D0=BA=D0=B8=D1=82=D0=B0=20=D0=A7=D0=B5=D1=80?= =?UTF-8?q?=D0=BD=D1=8B=D1=88=D0=BE=D0=B2?= Date: Thu, 4 May 2023 01:47:30 +0400 Subject: [PATCH] =?UTF-8?q?=D0=B2=D1=8B=D1=82=D1=8F=D0=B6=D0=BA=D0=B0=20?= =?UTF-8?q?=D0=B1=D0=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SubdShoeStore/Consignment.cs | 21 +++++ SubdShoeStore/Range.cs | 17 ++++ SubdShoeStore/Seller.cs | 17 ++++ SubdShoeStore/Selling.cs | 19 ++++ SubdShoeStore/Shoestorelab5Context.cs | 124 ++++++++++++++++++++++++++ SubdShoeStore/SubdShoeStore.csproj | 9 ++ 6 files changed, 207 insertions(+) create mode 100644 SubdShoeStore/Consignment.cs create mode 100644 SubdShoeStore/Range.cs create mode 100644 SubdShoeStore/Seller.cs create mode 100644 SubdShoeStore/Selling.cs create mode 100644 SubdShoeStore/Shoestorelab5Context.cs diff --git a/SubdShoeStore/Consignment.cs b/SubdShoeStore/Consignment.cs new file mode 100644 index 0000000..023782e --- /dev/null +++ b/SubdShoeStore/Consignment.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; + +namespace SubdShoeStore; + +public partial class Consignment +{ + public int Consignmentid { get; set; } + + public int Size { get; set; } + + public int Amount { get; set; } + + public DateOnly EnterDate { get; set; } + + public int Rangeid { get; set; } + + public virtual Range Range { get; set; } = null!; + + public virtual ICollection Sellings { get; set; } = new List(); +} diff --git a/SubdShoeStore/Range.cs b/SubdShoeStore/Range.cs new file mode 100644 index 0000000..4c27134 --- /dev/null +++ b/SubdShoeStore/Range.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; + +namespace SubdShoeStore; + +public partial class Range +{ + public int Rangeid { get; set; } + + public string Shoename { get; set; } = null!; + + public string Mfr { get; set; } = null!; + + public decimal Price { get; set; } + + public virtual ICollection Consignments { get; set; } = new List(); +} diff --git a/SubdShoeStore/Seller.cs b/SubdShoeStore/Seller.cs new file mode 100644 index 0000000..afe16cb --- /dev/null +++ b/SubdShoeStore/Seller.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; + +namespace SubdShoeStore; + +public partial class Seller +{ + public int Sellerid { get; set; } + + public string Surname { get; set; } = null!; + + public string Name { get; set; } = null!; + + public string PhoneNumber { get; set; } = null!; + + public virtual ICollection Sellings { get; set; } = new List(); +} diff --git a/SubdShoeStore/Selling.cs b/SubdShoeStore/Selling.cs new file mode 100644 index 0000000..966c225 --- /dev/null +++ b/SubdShoeStore/Selling.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; + +namespace SubdShoeStore; + +public partial class Selling +{ + public int Sellingid { get; set; } + + public int Sellerid { get; set; } + + public int Consignmentid { get; set; } + + public DateOnly SellDate { get; set; } + + public virtual Consignment Consignment { get; set; } = null!; + + public virtual Seller Seller { get; set; } = null!; +} diff --git a/SubdShoeStore/Shoestorelab5Context.cs b/SubdShoeStore/Shoestorelab5Context.cs new file mode 100644 index 0000000..2e89567 --- /dev/null +++ b/SubdShoeStore/Shoestorelab5Context.cs @@ -0,0 +1,124 @@ +using System; +using System.Collections.Generic; +using Microsoft.EntityFrameworkCore; + +namespace SubdShoeStore; + +public partial class Shoestorelab5Context : DbContext +{ + public Shoestorelab5Context() + { + } + + public Shoestorelab5Context(DbContextOptions options) + : base(options) + { + } + + public virtual DbSet Consignments { get; set; } + + public virtual DbSet Ranges { get; set; } + + public virtual DbSet Sellers { get; set; } + + public virtual DbSet Sellings { 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 http://go.microsoft.com/fwlink/?LinkId=723263. + => optionsBuilder.UseNpgsql("Host=192.168.56.101;Port=5432;Database=shoestorelab5;Username=postgres;Password=1804"); + + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + modelBuilder.Entity(entity => + { + entity.HasKey(e => e.Consignmentid).HasName("consignmentpk"); + + entity.ToTable("consignment"); + + entity.Property(e => e.Consignmentid) + .HasDefaultValueSql("nextval('seq_consignment'::regclass)") + .HasColumnName("consignmentid"); + entity.Property(e => e.Amount).HasColumnName("amount"); + entity.Property(e => e.EnterDate).HasColumnName("enter_date"); + entity.Property(e => e.Rangeid).HasColumnName("rangeid"); + entity.Property(e => e.Size).HasColumnName("size"); + + entity.HasOne(d => d.Range).WithMany(p => p.Consignments) + .HasForeignKey(d => d.Rangeid) + .OnDelete(DeleteBehavior.ClientSetNull) + .HasConstraintName("rangeconsignmentfk"); + }); + + modelBuilder.Entity(entity => + { + entity.HasKey(e => e.Rangeid).HasName("rangepk"); + + entity.ToTable("range"); + + entity.Property(e => e.Rangeid) + .HasDefaultValueSql("nextval('seq_range'::regclass)") + .HasColumnName("rangeid"); + entity.Property(e => e.Mfr) + .HasMaxLength(50) + .HasColumnName("mfr"); + entity.Property(e => e.Price) + .HasPrecision(10, 2) + .HasColumnName("price"); + entity.Property(e => e.Shoename) + .HasMaxLength(50) + .HasColumnName("shoename"); + }); + + modelBuilder.Entity(entity => + { + entity.HasKey(e => e.Sellerid).HasName("sellerpk"); + + entity.ToTable("seller"); + + entity.Property(e => e.Sellerid) + .HasDefaultValueSql("nextval('seq_seller'::regclass)") + .HasColumnName("sellerid"); + entity.Property(e => e.Name) + .HasMaxLength(50) + .HasColumnName("name"); + entity.Property(e => e.PhoneNumber) + .HasMaxLength(50) + .HasColumnName("phone_number"); + entity.Property(e => e.Surname) + .HasMaxLength(50) + .HasColumnName("surname"); + }); + + modelBuilder.Entity(entity => + { + entity.HasKey(e => e.Sellingid).HasName("sellingpk"); + + entity.ToTable("selling"); + + entity.Property(e => e.Sellingid) + .HasDefaultValueSql("nextval('seq_selling'::regclass)") + .HasColumnName("sellingid"); + entity.Property(e => e.Consignmentid).HasColumnName("consignmentid"); + entity.Property(e => e.SellDate).HasColumnName("sell_date"); + entity.Property(e => e.Sellerid).HasColumnName("sellerid"); + + entity.HasOne(d => d.Consignment).WithMany(p => p.Sellings) + .HasForeignKey(d => d.Consignmentid) + .OnDelete(DeleteBehavior.ClientSetNull) + .HasConstraintName("consignmentfk"); + + entity.HasOne(d => d.Seller).WithMany(p => p.Sellings) + .HasForeignKey(d => d.Sellerid) + .OnDelete(DeleteBehavior.ClientSetNull) + .HasConstraintName("sellerfk"); + }); + modelBuilder.HasSequence("seq_consignment"); + modelBuilder.HasSequence("seq_range"); + modelBuilder.HasSequence("seq_seller"); + modelBuilder.HasSequence("seq_selling"); + + OnModelCreatingPartial(modelBuilder); + } + + partial void OnModelCreatingPartial(ModelBuilder modelBuilder); +} diff --git a/SubdShoeStore/SubdShoeStore.csproj b/SubdShoeStore/SubdShoeStore.csproj index 74abf5c..4f8ddd5 100644 --- a/SubdShoeStore/SubdShoeStore.csproj +++ b/SubdShoeStore/SubdShoeStore.csproj @@ -7,4 +7,13 @@ enable + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + +