From 2ab4d14a58396a52bbd89e3cd50be2050c3724ad Mon Sep 17 00:00:00 2001 From: Kenan KARAER Date: Sat, 9 Aug 2025 23:14:48 +0300 Subject: [PATCH 1/2] il, ilce tablosu eklendi. --- FrmAddKullanici.cs | 16 +- FrmLogin.cs | 2 +- Migrations/20250809145150_mg7.Designer.cs | 152 +++++++++++ Migrations/20250809145150_mg7.cs | 250 ++++++++++++++++++ Migrations/20250809153336_mg8.Designer.cs | 173 ++++++++++++ Migrations/20250809153336_mg8.cs | 36 +++ Migrations/dugunsalonuContextModelSnapshot.cs | 160 ++++++----- Models/Il.cs | 10 +- Models/Ilce.cs | 29 ++ Models/Kullanici.cs | 31 +-- Models/Salon.cs | 35 ++- Models/dugunsalonuContext.cs | 5 +- 12 files changed, 773 insertions(+), 126 deletions(-) create mode 100644 Migrations/20250809145150_mg7.Designer.cs create mode 100644 Migrations/20250809145150_mg7.cs create mode 100644 Migrations/20250809153336_mg8.Designer.cs create mode 100644 Migrations/20250809153336_mg8.cs create mode 100644 Models/Ilce.cs diff --git a/FrmAddKullanici.cs b/FrmAddKullanici.cs index 4ea9527..392854f 100644 --- a/FrmAddKullanici.cs +++ b/FrmAddKullanici.cs @@ -21,14 +21,14 @@ namespace DugunSalonu { await db.kullanici.AddAsync(new Kullanici { - Adi = txtAdi.Text, - Soyadi = txtSoyadi.Text, - KullaniciAdi = txtKullaniciAdi.Text, - Parola = txtParola.Text, - Aktif = true, - Admin = false, - CepTel = txtCeptel.Text, - Eposta = txtEposta.Text + adi = txtAdi.Text, + soyadi = txtSoyadi.Text, + kullaniciadi = txtKullaniciAdi.Text, + parola = txtParola.Text, + aktif = true, + admin = false, + ceptel = txtCeptel.Text, + eposta = txtEposta.Text }); await db.SaveChangesAsync(); FormTemizle(); diff --git a/FrmLogin.cs b/FrmLogin.cs index b6a29cb..cc64998 100644 --- a/FrmLogin.cs +++ b/FrmLogin.cs @@ -29,7 +29,7 @@ namespace DugunSalonu { using (dugunsalonuContext db = new dugunsalonuContext()) { - var user = await db.kullanici.Where(k => k.KullaniciAdi == txtKullanici.Text && k.Aktif == true && k.Parola == txtSifre.Text).FirstOrDefaultAsync(); + var user = await db.kullanici.Where(k => k.kullaniciadi == txtKullanici.Text && k.aktif == true && k.parola == txtSifre.Text).FirstOrDefaultAsync(); if (user != null) { FrmAddKullanici f1 = new FrmAddKullanici(); diff --git a/Migrations/20250809145150_mg7.Designer.cs b/Migrations/20250809145150_mg7.Designer.cs new file mode 100644 index 0000000..3d2da31 --- /dev/null +++ b/Migrations/20250809145150_mg7.Designer.cs @@ -0,0 +1,152 @@ +// +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("20250809145150_mg7")] + partial class mg7 + { + /// + 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.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.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/20250809145150_mg7.cs b/Migrations/20250809145150_mg7.cs new file mode 100644 index 0000000..0cbc4fb --- /dev/null +++ b/Migrations/20250809145150_mg7.cs @@ -0,0 +1,250 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace DugunSalonu.Migrations +{ + /// + public partial class mg7 : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_salon_il_ılıd", + table: "salon"); + + migrationBuilder.DropColumn( + name: "ılce", + table: "salon"); + + migrationBuilder.RenameColumn( + name: "ceptel", + table: "salon", + newName: "CepTel"); + + migrationBuilder.RenameColumn( + name: "ılıd", + table: "salon", + newName: "ilid"); + + migrationBuilder.RenameColumn( + name: "ıd", + table: "salon", + newName: "id"); + + migrationBuilder.RenameIndex( + name: "IX_salon_ılıd", + table: "salon", + newName: "IX_salon_ilid"); + + migrationBuilder.RenameColumn( + name: "ıd", + table: "kullanici", + newName: "id"); + + migrationBuilder.RenameColumn( + name: "ıd", + table: "il", + newName: "id"); + + migrationBuilder.AlterColumn( + name: "webadres", + table: "salon", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text"); + + migrationBuilder.AlterColumn( + name: "verginumarasi", + table: "salon", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text"); + + migrationBuilder.AlterColumn( + name: "vergidairesi", + table: "salon", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text"); + + migrationBuilder.AlterColumn( + name: "telefon", + table: "salon", + type: "text", + nullable: true, + oldClrType: typeof(string), + oldType: "text"); + + migrationBuilder.AlterColumn( + name: "adres", + table: "salon", + type: "character varying(250)", + maxLength: 250, + nullable: true, + oldClrType: typeof(string), + oldType: "text"); + + migrationBuilder.AlterColumn( + name: "adi", + table: "salon", + type: "character varying(150)", + maxLength: 150, + nullable: false, + oldClrType: typeof(string), + oldType: "text"); + + migrationBuilder.AlterColumn( + name: "ilid", + table: "salon", + type: "integer", + nullable: true, + oldClrType: typeof(int), + oldType: "integer"); + + migrationBuilder.AddColumn( + name: "ilceid", + table: "salon", + type: "integer", + nullable: true); + + migrationBuilder.AddForeignKey( + name: "FK_salon_il_ilid", + table: "salon", + column: "ilid", + principalTable: "il", + principalColumn: "id"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_salon_il_ilid", + table: "salon"); + + migrationBuilder.DropColumn( + name: "ilceid", + table: "salon"); + + migrationBuilder.RenameColumn( + name: "CepTel", + table: "salon", + newName: "ceptel"); + + migrationBuilder.RenameColumn( + name: "ilid", + table: "salon", + newName: "ılıd"); + + migrationBuilder.RenameColumn( + name: "id", + table: "salon", + newName: "ıd"); + + migrationBuilder.RenameIndex( + name: "IX_salon_ilid", + table: "salon", + newName: "IX_salon_ılıd"); + + migrationBuilder.RenameColumn( + name: "id", + table: "kullanici", + newName: "ıd"); + + migrationBuilder.RenameColumn( + name: "id", + table: "il", + newName: "ıd"); + + migrationBuilder.AlterColumn( + name: "webadres", + table: "salon", + type: "text", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "verginumarasi", + table: "salon", + type: "text", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "vergidairesi", + table: "salon", + type: "text", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "telefon", + table: "salon", + type: "text", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "text", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "adres", + table: "salon", + type: "text", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "character varying(250)", + oldMaxLength: 250, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "adi", + table: "salon", + type: "text", + nullable: false, + oldClrType: typeof(string), + oldType: "character varying(150)", + oldMaxLength: 150); + + migrationBuilder.AlterColumn( + name: "ılıd", + table: "salon", + type: "integer", + nullable: false, + defaultValue: 0, + oldClrType: typeof(int), + oldType: "integer", + oldNullable: true); + + migrationBuilder.AddColumn( + name: "ılce", + table: "salon", + type: "integer", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddForeignKey( + name: "FK_salon_il_ılıd", + table: "salon", + column: "ılıd", + principalTable: "il", + principalColumn: "ıd", + onDelete: ReferentialAction.Cascade); + } + } +} diff --git a/Migrations/20250809153336_mg8.Designer.cs b/Migrations/20250809153336_mg8.Designer.cs new file mode 100644 index 0000000..c3df53f --- /dev/null +++ b/Migrations/20250809153336_mg8.Designer.cs @@ -0,0 +1,173 @@ +// +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("20250809153336_mg8")] + partial class mg8 + { + /// + 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.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/20250809153336_mg8.cs b/Migrations/20250809153336_mg8.cs new file mode 100644 index 0000000..0e6f1bd --- /dev/null +++ b/Migrations/20250809153336_mg8.cs @@ -0,0 +1,36 @@ +using Microsoft.EntityFrameworkCore.Migrations; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace DugunSalonu.Migrations +{ + /// + public partial class mg8 : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "ilce", + columns: table => new + { + id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + adi = table.Column(type: "character varying(50)", maxLength: 50, nullable: false), + ilid = table.Column(type: "integer", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_ilce", x => x.id); + }); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "ilce"); + } + } +} diff --git a/Migrations/dugunsalonuContextModelSnapshot.cs b/Migrations/dugunsalonuContextModelSnapshot.cs index 235fa9c..f9f4cf5 100644 --- a/Migrations/dugunsalonuContextModelSnapshot.cs +++ b/Migrations/dugunsalonuContextModelSnapshot.cs @@ -23,139 +23,135 @@ namespace DugunSalonu.Migrations modelBuilder.Entity("DugunSalonu.Models.Il", b => { - b.Property("Id") + b.Property("id") .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasColumnName("ıd"); + .HasColumnType("integer"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("id")); - b.Property("Adi") + b.Property("adi") .IsRequired() - .HasColumnType("text") - .HasColumnName("adi"); + .HasColumnType("text"); - b.HasKey("Id"); + 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") + b.Property("id") .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasColumnName("ıd"); + .HasColumnType("integer"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("id")); - b.Property("Adi") + b.Property("adi") .IsRequired() .HasMaxLength(50) - .HasColumnType("character varying(50)") - .HasColumnName("adi"); + .HasColumnType("character varying(50)"); - b.Property("Admin") - .HasColumnType("boolean") - .HasColumnName("admin"); + b.Property("admin") + .HasColumnType("boolean"); - b.Property("Aktif") - .HasColumnType("boolean") - .HasColumnName("aktif"); + b.Property("aktif") + .HasColumnType("boolean"); - b.Property("CepTel") + b.Property("ceptel") .HasMaxLength(10) - .HasColumnType("character varying(10)") - .HasColumnName("ceptel"); + .HasColumnType("character varying(10)"); - b.Property("Eposta") + b.Property("eposta") .HasMaxLength(50) - .HasColumnType("character varying(50)") - .HasColumnName("eposta"); + .HasColumnType("character varying(50)"); - b.Property("KullaniciAdi") + b.Property("kullaniciadi") .IsRequired() .HasMaxLength(50) - .HasColumnType("character varying(50)") - .HasColumnName("kullaniciadi"); + .HasColumnType("character varying(50)"); - b.Property("Parola") + b.Property("parola") .IsRequired() - .HasColumnType("text") - .HasColumnName("parola"); + .HasColumnType("text"); - b.Property("Soyadi") + b.Property("soyadi") .IsRequired() .HasMaxLength(50) - .HasColumnType("character varying(50)") - .HasColumnName("soyadi"); + .HasColumnType("character varying(50)"); - b.HasKey("Id"); + b.HasKey("id"); b.ToTable("kullanici"); }); modelBuilder.Entity("DugunSalonu.Models.Salon", b => { - b.Property("Id") + b.Property("id") .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasColumnName("ıd"); + .HasColumnType("integer"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Adi") - .IsRequired() - .HasColumnType("text") - .HasColumnName("adi"); - - b.Property("Adres") - .IsRequired() - .HasColumnType("text") - .HasColumnName("adres"); + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("id")); b.Property("CepTel") .IsRequired() .HasMaxLength(10) - .HasColumnType("character varying(10)") - .HasColumnName("ceptel"); + .HasColumnType("character varying(10)"); - b.Property("Eposta") + b.Property("adi") .IsRequired() - .HasColumnType("text") - .HasColumnName("eposta"); + .HasMaxLength(150) + .HasColumnType("character varying(150)"); - b.Property("IlId") - .HasColumnType("integer") - .HasColumnName("ılıd"); + b.Property("adres") + .HasMaxLength(250) + .HasColumnType("character varying(250)"); - b.Property("Ilce") - .HasColumnType("integer") - .HasColumnName("ılce"); - - b.Property("Telefon") + b.Property("eposta") .IsRequired() - .HasColumnType("text") - .HasColumnName("telefon"); + .HasColumnType("text"); - b.Property("VergiDairesi") - .IsRequired() - .HasColumnType("text") - .HasColumnName("vergidairesi"); + b.Property("ilceid") + .HasColumnType("integer"); - b.Property("VergiNumarasi") - .IsRequired() - .HasColumnType("text") - .HasColumnName("verginumarasi"); + b.Property("ilid") + .HasColumnType("integer"); - b.Property("WebAdres") - .IsRequired() - .HasColumnType("text") - .HasColumnName("webadres"); + b.Property("telefon") + .HasColumnType("text"); - b.HasKey("Id"); + b.Property("vergidairesi") + .HasColumnType("text"); - b.HasIndex("IlId"); + b.Property("verginumarasi") + .HasColumnType("text"); + + b.Property("webadres") + .HasColumnType("text"); + + b.HasKey("id"); + + b.HasIndex("ilid"); b.ToTable("salon"); }); @@ -164,9 +160,7 @@ namespace DugunSalonu.Migrations { b.HasOne("DugunSalonu.Models.Il", "il") .WithMany() - .HasForeignKey("IlId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + .HasForeignKey("ilid"); b.Navigation("il"); }); diff --git a/Models/Il.cs b/Models/Il.cs index 4ab9102..67d6939 100644 --- a/Models/Il.cs +++ b/Models/Il.cs @@ -10,13 +10,11 @@ namespace DugunSalonu.Models public class Il { - public Il() - { - salons = new HashSet(); - } + public Il() => salons = new HashSet(); + [Key] - public int Id { get; set; } - public string Adi { get; set; } + public int id { get; set; } + public string adi { get; set; } ICollection? salons { get; set; } } diff --git a/Models/Ilce.cs b/Models/Ilce.cs new file mode 100644 index 0000000..4821d0f --- /dev/null +++ b/Models/Ilce.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DugunSalonu.Models +{ + internal class Ilce + { + public Ilce() + { + il = new HashSet(); + } + + [Key] + public int id { get; set; } + [Required] + [MaxLength(50)] + public required string adi { get; set; } + [Required] + public required int ilid { get; set; } + ICollection? il { get; set; } + + ICollection? ilce { get; set; } + + } +} diff --git a/Models/Kullanici.cs b/Models/Kullanici.cs index 02b3e5a..773842f 100644 --- a/Models/Kullanici.cs +++ b/Models/Kullanici.cs @@ -11,27 +11,28 @@ namespace DugunSalonu.Models internal class Kullanici { [Key] - public int Id { get; set; } + public int id { get; set; } + [MaxLength(50), MinLength(5)] [Required] + public required string kullaniciadi { get; set; } + [Required] + [MaxLength(50)] + public required string adi { get; set; } + + [Required] + [MaxLength(50)] + public required string soyadi { get; set; } - public required string KullaniciAdi { get; set; } + public string adisoyadi { get { return $"{adi} {soyadi}"; } } [Required] + public required string parola { get; set; } [MaxLength(50)] - public required string Adi { get; set; } - [Required] - [MaxLength(50)] - public required string Soyadi { get; set; } - - public string AdiSoyadi { get { return $"{Adi} {Soyadi}"; } } - [Required] - public required string Parola { get; set; } - [MaxLength(50)] - public string? Eposta { get; set; } + public string? eposta { get; set; } [MaxLength(10), MinLength(10)] - public string? CepTel { get; set; } - public bool Aktif { get; set; } - public bool Admin { get; set; } + public string? ceptel { get; set; } + public bool aktif { get; set; } + public bool admin { get; set; } } } diff --git a/Models/Salon.cs b/Models/Salon.cs index e8ef94c..38a47ae 100644 --- a/Models/Salon.cs +++ b/Models/Salon.cs @@ -10,20 +10,33 @@ namespace DugunSalonu.Models public class Salon { [Key] - public int Id { get; set; } - public string Adi { get; set; } - public string Adres { get; set; } - public int IlId { get; set; } - public int Ilce { get; set; } - public string Eposta { get; set; } - public string VergiDairesi { get; set; } - public string VergiNumarasi { get; set; } - public string Telefon { get; set; } + public int id { get; set; } + [Required] + [MaxLength(150)] + [MinLength(5)] + public required string adi { get; set; } + + [MaxLength(250)] + public string? adres { get; set; } + public int? ilid { get; set; } + public int? ilceid { get; set; } + + [Required] + public required string eposta { get; set; } + public string? vergidairesi { get; set; } + public string? verginumarasi { get; set; } + + + public string? telefon { get; set; } + [Required] [MaxLength(10), MinLength(10)] - public string CepTel { get; set; } - public string WebAdres { get; set; } + public required string CepTel { get; set; } + public string? webadres { get; set; } public Il? il { get; set; } + + + } } diff --git a/Models/dugunsalonuContext.cs b/Models/dugunsalonuContext.cs index da41005..2ec226d 100644 --- a/Models/dugunsalonuContext.cs +++ b/Models/dugunsalonuContext.cs @@ -15,6 +15,7 @@ namespace DugunSalonu.Models public DbSet salon { get; set; } public DbSet il { get; set; } + public DbSet ilce { get; set; } protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { @@ -22,7 +23,7 @@ namespace DugunSalonu.Models base.OnConfiguring(optionsBuilder); } - protected override void OnModelCreating(ModelBuilder modelBuilder) + /*protected override void OnModelCreating(ModelBuilder modelBuilder) { base.OnModelCreating(modelBuilder); @@ -38,6 +39,6 @@ namespace DugunSalonu.Models // İsteğe bağlı: Tablo isimlerini de büyük harfe dönüştür (eğer istiyorsanız) entityType.SetTableName(entityType.GetTableName().ToLower()); } - } + }*/ } } From ab7878a43be89f587913c51a57d62551c1d567bf Mon Sep 17 00:00:00 2001 From: Kenan KARAER Date: Sun, 10 Aug 2025 17:21:52 +0300 Subject: [PATCH 2/2] =?UTF-8?q?referans=20tablosu=20=C3=BCretildi.=20T?= =?UTF-8?q?=C3=BCr=C3=BC=20ve=20Kodu=20i=C3=A7in=20kontrol=20sa=C4=9Fland?= =?UTF-8?q?=C4=B1.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Migrations/20250810141631_mg9.Designer.cs | 216 ++++++++++++++++++ Migrations/20250810141631_mg9.cs | 47 ++++ Migrations/dugunsalonuContextModelSnapshot.cs | 43 ++++ Models/Referans.cs | 35 +++ Models/dugunsalonuContext.cs | 15 ++ 5 files changed, 356 insertions(+) create mode 100644 Migrations/20250810141631_mg9.Designer.cs create mode 100644 Migrations/20250810141631_mg9.cs create mode 100644 Models/Referans.cs 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());