diff --git a/Migrations/20250810141631_mg9.Designer.cs b/Migrations/20250810141631_mg9.Designer.cs new file mode 100644 index 0000000..bd26a14 --- /dev/null +++ b/Migrations/20250810141631_mg9.Designer.cs @@ -0,0 +1,216 @@ +// +using System; +using DugunSalonu.Models; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace DugunSalonu.Migrations +{ + [DbContext(typeof(dugunsalonuContext))] + [Migration("20250810141631_mg9")] + partial class mg9 + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "9.0.7") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("DugunSalonu.Models.Il", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("id")); + + b.Property("adi") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("id"); + + b.ToTable("il"); + }); + + modelBuilder.Entity("DugunSalonu.Models.Ilce", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("id")); + + b.Property("adi") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("ilid") + .HasColumnType("integer"); + + b.HasKey("id"); + + b.ToTable("ilce"); + }); + + modelBuilder.Entity("DugunSalonu.Models.Kullanici", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("id")); + + b.Property("adi") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("admin") + .HasColumnType("boolean"); + + b.Property("aktif") + .HasColumnType("boolean"); + + b.Property("ceptel") + .HasMaxLength(10) + .HasColumnType("character varying(10)"); + + b.Property("eposta") + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("kullaniciadi") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("parola") + .IsRequired() + .HasColumnType("text"); + + b.Property("soyadi") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.HasKey("id"); + + b.ToTable("kullanici"); + }); + + modelBuilder.Entity("DugunSalonu.Models.Referans", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("id")); + + b.Property("adi") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("aktif") + .HasColumnType("boolean"); + + b.Property("kk") + .HasColumnType("integer"); + + b.Property("kodu") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("character varying(20)"); + + b.Property("kts") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasDefaultValueSql("NOW()"); + + b.Property("turu") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.HasKey("id"); + + b.HasIndex("turu", "kodu") + .IsUnique(); + + b.ToTable("referans"); + }); + + modelBuilder.Entity("DugunSalonu.Models.Salon", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("id")); + + b.Property("CepTel") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("character varying(10)"); + + b.Property("adi") + .IsRequired() + .HasMaxLength(150) + .HasColumnType("character varying(150)"); + + b.Property("adres") + .HasMaxLength(250) + .HasColumnType("character varying(250)"); + + b.Property("eposta") + .IsRequired() + .HasColumnType("text"); + + b.Property("ilceid") + .HasColumnType("integer"); + + b.Property("ilid") + .HasColumnType("integer"); + + b.Property("telefon") + .HasColumnType("text"); + + b.Property("vergidairesi") + .HasColumnType("text"); + + b.Property("verginumarasi") + .HasColumnType("text"); + + b.Property("webadres") + .HasColumnType("text"); + + b.HasKey("id"); + + b.HasIndex("ilid"); + + b.ToTable("salon"); + }); + + modelBuilder.Entity("DugunSalonu.Models.Salon", b => + { + b.HasOne("DugunSalonu.Models.Il", "il") + .WithMany() + .HasForeignKey("ilid"); + + b.Navigation("il"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Migrations/20250810141631_mg9.cs b/Migrations/20250810141631_mg9.cs new file mode 100644 index 0000000..988b8b0 --- /dev/null +++ b/Migrations/20250810141631_mg9.cs @@ -0,0 +1,47 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace DugunSalonu.Migrations +{ + /// + public partial class mg9 : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "referans", + columns: table => new + { + id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + turu = table.Column(type: "character varying(50)", maxLength: 50, nullable: false), + kodu = table.Column(type: "character varying(20)", maxLength: 20, nullable: false), + adi = table.Column(type: "character varying(50)", maxLength: 50, nullable: false), + kts = table.Column(type: "timestamp with time zone", nullable: false, defaultValueSql: "NOW()"), + kk = table.Column(type: "integer", nullable: false), + aktif = table.Column(type: "boolean", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_referans", x => x.id); + }); + + migrationBuilder.CreateIndex( + name: "IX_referans_turu_kodu", + table: "referans", + columns: new[] { "turu", "kodu" }, + unique: true); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "referans"); + } + } +} diff --git a/Migrations/dugunsalonuContextModelSnapshot.cs b/Migrations/dugunsalonuContextModelSnapshot.cs index f9f4cf5..74d9955 100644 --- a/Migrations/dugunsalonuContextModelSnapshot.cs +++ b/Migrations/dugunsalonuContextModelSnapshot.cs @@ -1,4 +1,5 @@ // +using System; using DugunSalonu.Models; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; @@ -105,6 +106,48 @@ namespace DugunSalonu.Migrations b.ToTable("kullanici"); }); + modelBuilder.Entity("DugunSalonu.Models.Referans", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("id")); + + b.Property("adi") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("aktif") + .HasColumnType("boolean"); + + b.Property("kk") + .HasColumnType("integer"); + + b.Property("kodu") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("character varying(20)"); + + b.Property("kts") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasDefaultValueSql("NOW()"); + + b.Property("turu") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.HasKey("id"); + + b.HasIndex("turu", "kodu") + .IsUnique(); + + b.ToTable("referans"); + }); + modelBuilder.Entity("DugunSalonu.Models.Salon", b => { b.Property("id") diff --git a/Models/Referans.cs b/Models/Referans.cs new file mode 100644 index 0000000..afdf5c8 --- /dev/null +++ b/Models/Referans.cs @@ -0,0 +1,35 @@ +using Microsoft.EntityFrameworkCore; +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms.VisualStyles; + +namespace DugunSalonu.Models +{ + public class Referans + { + [Key] + public int id { get; set; } + + [Required] + [MaxLength(50)] + public required string turu { get; set; } + [Required] + [MaxLength(20)] + public required string kodu { get; set; } + [Required] + [MaxLength(50)] + public required string adi { get; set; } + [Required] + public required DateTime kts { get; set; } + [Required] + public required int kk { get; set; } + + public bool aktif { get; set; } + + + } +} diff --git a/Models/dugunsalonuContext.cs b/Models/dugunsalonuContext.cs index 2ec226d..3409d51 100644 --- a/Models/dugunsalonuContext.cs +++ b/Models/dugunsalonuContext.cs @@ -17,6 +17,21 @@ namespace DugunSalonu.Models public DbSet ilce { get; set; } + public DbSet referans { get; set; } + + + + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + modelBuilder.Entity() + .HasIndex(r => new { r.turu, r.kodu }) + .IsUnique(); + + // kts alanı için default değer + modelBuilder.Entity() + .Property(r => r.kts) + .HasDefaultValueSql("NOW()"); + } protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { optionsBuilder.UseNpgsql("Server=edoysoft.com;Database=DugunSalonu;User Id=postgres;Password=MgC1453MgC;", b => b.EnableRetryOnFailure());