güncelleme

This commit is contained in:
2025-08-11 11:22:31 +03:00
parent 5616230e67
commit 5c7bb2c399
10 changed files with 599 additions and 55 deletions

View File

@@ -0,0 +1,210 @@
// <auto-generated />
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("20250811081119_mig10")]
partial class mig10
{
/// <inheritdoc />
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<int>("id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("id"));
b.Property<string>("adi")
.IsRequired()
.HasColumnType("text");
b.HasKey("id");
b.ToTable("il");
});
modelBuilder.Entity("DugunSalonu.Models.Ilce", b =>
{
b.Property<int>("id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("id"));
b.Property<int>("ILid")
.HasColumnType("integer")
.HasColumnName("ilid");
b.Property<string>("adi")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.HasKey("id");
b.ToTable("ilce");
});
modelBuilder.Entity("DugunSalonu.Models.Kullanici", b =>
{
b.Property<int>("id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("id"));
b.Property<string>("adi")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<bool>("admin")
.HasColumnType("boolean");
b.Property<bool>("aktif")
.HasColumnType("boolean");
b.Property<string>("ceptel")
.HasMaxLength(10)
.HasColumnType("character varying(10)");
b.Property<string>("eposta")
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<string>("kullaniciadi")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<string>("parola")
.IsRequired()
.HasColumnType("text");
b.Property<string>("soyadi")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.HasKey("id");
b.ToTable("kullanici");
});
modelBuilder.Entity("DugunSalonu.Models.Referans", b =>
{
b.Property<string>("adi")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<bool>("aktif")
.HasColumnType("boolean");
b.Property<int>("id")
.HasColumnType("integer");
b.Property<int>("kk")
.HasColumnType("integer");
b.Property<string>("kodu")
.IsRequired()
.HasMaxLength(20)
.HasColumnType("character varying(20)");
b.Property<DateTime>("kts")
.HasColumnType("timestamp with time zone");
b.Property<string>("turu")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.HasIndex("turu", "kodu")
.IsUnique();
b.ToTable("referans");
});
modelBuilder.Entity("DugunSalonu.Models.Salon", b =>
{
b.Property<int>("id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("id"));
b.Property<string>("CepTel")
.IsRequired()
.HasMaxLength(10)
.HasColumnType("character varying(10)");
b.Property<string>("adi")
.IsRequired()
.HasMaxLength(150)
.HasColumnType("character varying(150)");
b.Property<string>("adres")
.HasMaxLength(250)
.HasColumnType("character varying(250)");
b.Property<string>("eposta")
.IsRequired()
.HasColumnType("text");
b.Property<int?>("ilceid")
.HasColumnType("integer");
b.Property<int?>("ilid")
.HasColumnType("integer");
b.Property<string>("telefon")
.HasColumnType("text");
b.Property<string>("vergidairesi")
.HasColumnType("text");
b.Property<string>("verginumarasi")
.HasColumnType("text");
b.Property<string>("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
}
}
}

View File

@@ -0,0 +1,65 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace DugunSalonu.Migrations
{
/// <inheritdoc />
public partial class mig10 : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropPrimaryKey(
name: "PK_referans",
table: "referans");
migrationBuilder.AlterColumn<DateTime>(
name: "kts",
table: "referans",
type: "timestamp with time zone",
nullable: false,
oldClrType: typeof(DateTime),
oldType: "timestamp with time zone",
oldDefaultValueSql: "NOW()");
migrationBuilder.AlterColumn<int>(
name: "id",
table: "referans",
type: "integer",
nullable: false,
oldClrType: typeof(int),
oldType: "integer")
.OldAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<DateTime>(
name: "kts",
table: "referans",
type: "timestamp with time zone",
nullable: false,
defaultValueSql: "NOW()",
oldClrType: typeof(DateTime),
oldType: "timestamp with time zone");
migrationBuilder.AlterColumn<int>(
name: "id",
table: "referans",
type: "integer",
nullable: false,
oldClrType: typeof(int),
oldType: "integer")
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
migrationBuilder.AddPrimaryKey(
name: "PK_referans",
table: "referans",
column: "id");
}
}
}

View File

@@ -0,0 +1,230 @@
// <auto-generated />
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("20250811082022_mig11")]
partial class mig11
{
/// <inheritdoc />
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<int>("id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("id"));
b.Property<string>("adi")
.IsRequired()
.HasColumnType("text");
b.HasKey("id");
b.ToTable("il");
});
modelBuilder.Entity("DugunSalonu.Models.Ilce", b =>
{
b.Property<int>("id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("id"));
b.Property<int>("ILid")
.HasColumnType("integer")
.HasColumnName("ilid");
b.Property<string>("adi")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.HasKey("id");
b.HasIndex("ILid");
b.ToTable("ilce");
});
modelBuilder.Entity("DugunSalonu.Models.Kullanici", b =>
{
b.Property<int>("id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("id"));
b.Property<string>("adi")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<bool>("admin")
.HasColumnType("boolean");
b.Property<bool>("aktif")
.HasColumnType("boolean");
b.Property<string>("ceptel")
.HasMaxLength(10)
.HasColumnType("character varying(10)");
b.Property<string>("eposta")
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<string>("kullaniciadi")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<string>("parola")
.IsRequired()
.HasColumnType("text");
b.Property<string>("soyadi")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.HasKey("id");
b.ToTable("kullanici");
});
modelBuilder.Entity("DugunSalonu.Models.Referans", b =>
{
b.Property<string>("adi")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<bool>("aktif")
.HasColumnType("boolean");
b.Property<int>("id")
.HasColumnType("integer");
b.Property<int>("kk")
.HasColumnType("integer");
b.Property<string>("kodu")
.IsRequired()
.HasMaxLength(20)
.HasColumnType("character varying(20)");
b.Property<DateTime>("kts")
.HasColumnType("timestamp with time zone");
b.Property<string>("turu")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.HasIndex("turu", "kodu")
.IsUnique();
b.ToTable("referans");
});
modelBuilder.Entity("DugunSalonu.Models.Salon", b =>
{
b.Property<int>("id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("id"));
b.Property<string>("CepTel")
.IsRequired()
.HasMaxLength(10)
.HasColumnType("character varying(10)");
b.Property<string>("adi")
.IsRequired()
.HasMaxLength(150)
.HasColumnType("character varying(150)");
b.Property<string>("adres")
.HasMaxLength(250)
.HasColumnType("character varying(250)");
b.Property<string>("eposta")
.IsRequired()
.HasColumnType("text");
b.Property<int?>("ilceid")
.HasColumnType("integer");
b.Property<int?>("ilid")
.HasColumnType("integer");
b.Property<string>("telefon")
.HasColumnType("text");
b.Property<string>("vergidairesi")
.HasColumnType("text");
b.Property<string>("verginumarasi")
.HasColumnType("text");
b.Property<string>("webadres")
.HasColumnType("text");
b.HasKey("id");
b.HasIndex("ilid");
b.ToTable("salon");
});
modelBuilder.Entity("DugunSalonu.Models.Ilce", b =>
{
b.HasOne("DugunSalonu.Models.Il", "Il")
.WithMany("ilceler")
.HasForeignKey("ILid")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Il");
});
modelBuilder.Entity("DugunSalonu.Models.Salon", b =>
{
b.HasOne("DugunSalonu.Models.Il", "il")
.WithMany("salons")
.HasForeignKey("ilid");
b.Navigation("il");
});
modelBuilder.Entity("DugunSalonu.Models.Il", b =>
{
b.Navigation("ilceler");
b.Navigation("salons");
});
#pragma warning restore 612, 618
}
}
}

View File

@@ -0,0 +1,39 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace DugunSalonu.Migrations
{
/// <inheritdoc />
public partial class mig11 : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateIndex(
name: "IX_ilce_ilid",
table: "ilce",
column: "ilid");
migrationBuilder.AddForeignKey(
name: "FK_ilce_il_ilid",
table: "ilce",
column: "ilid",
principalTable: "il",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_ilce_il_ilid",
table: "ilce");
migrationBuilder.DropIndex(
name: "IX_ilce_ilid",
table: "ilce");
}
}
}

View File

@@ -47,16 +47,19 @@ namespace DugunSalonu.Migrations
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("id")); NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("id"));
b.Property<int>("ILid")
.HasColumnType("integer")
.HasColumnName("ilid");
b.Property<string>("adi") b.Property<string>("adi")
.IsRequired() .IsRequired()
.HasMaxLength(50) .HasMaxLength(50)
.HasColumnType("character varying(50)"); .HasColumnType("character varying(50)");
b.Property<int>("ilid")
.HasColumnType("integer");
b.HasKey("id"); b.HasKey("id");
b.HasIndex("ILid");
b.ToTable("ilce"); b.ToTable("ilce");
}); });
@@ -108,12 +111,6 @@ namespace DugunSalonu.Migrations
modelBuilder.Entity("DugunSalonu.Models.Referans", b => modelBuilder.Entity("DugunSalonu.Models.Referans", b =>
{ {
b.Property<int>("id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("id"));
b.Property<string>("adi") b.Property<string>("adi")
.IsRequired() .IsRequired()
.HasMaxLength(50) .HasMaxLength(50)
@@ -122,6 +119,9 @@ namespace DugunSalonu.Migrations
b.Property<bool>("aktif") b.Property<bool>("aktif")
.HasColumnType("boolean"); .HasColumnType("boolean");
b.Property<int>("id")
.HasColumnType("integer");
b.Property<int>("kk") b.Property<int>("kk")
.HasColumnType("integer"); .HasColumnType("integer");
@@ -131,17 +131,13 @@ namespace DugunSalonu.Migrations
.HasColumnType("character varying(20)"); .HasColumnType("character varying(20)");
b.Property<DateTime>("kts") b.Property<DateTime>("kts")
.ValueGeneratedOnAdd() .HasColumnType("timestamp with time zone");
.HasColumnType("timestamp with time zone")
.HasDefaultValueSql("NOW()");
b.Property<string>("turu") b.Property<string>("turu")
.IsRequired() .IsRequired()
.HasMaxLength(50) .HasMaxLength(50)
.HasColumnType("character varying(50)"); .HasColumnType("character varying(50)");
b.HasKey("id");
b.HasIndex("turu", "kodu") b.HasIndex("turu", "kodu")
.IsUnique(); .IsUnique();
@@ -199,14 +195,32 @@ namespace DugunSalonu.Migrations
b.ToTable("salon"); b.ToTable("salon");
}); });
modelBuilder.Entity("DugunSalonu.Models.Ilce", b =>
{
b.HasOne("DugunSalonu.Models.Il", "Il")
.WithMany("ilceler")
.HasForeignKey("ILid")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Il");
});
modelBuilder.Entity("DugunSalonu.Models.Salon", b => modelBuilder.Entity("DugunSalonu.Models.Salon", b =>
{ {
b.HasOne("DugunSalonu.Models.Il", "il") b.HasOne("DugunSalonu.Models.Il", "il")
.WithMany() .WithMany("salons")
.HasForeignKey("ilid"); .HasForeignKey("ilid");
b.Navigation("il"); b.Navigation("il");
}); });
modelBuilder.Entity("DugunSalonu.Models.Il", b =>
{
b.Navigation("ilceler");
b.Navigation("salons");
});
#pragma warning restore 612, 618 #pragma warning restore 612, 618
} }
} }

View File

@@ -16,6 +16,7 @@ namespace DugunSalonu.Models
public int id { get; set; } public int id { get; set; }
public string adi { get; set; } public string adi { get; set; }
ICollection<Salon>? salons { get; set; } public ICollection<Salon>? salons { get; set; }
public ICollection<Ilce>? ilceler { get; set; }
} }
} }

View File

@@ -1,18 +1,16 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace DugunSalonu.Models namespace DugunSalonu.Models
{ {
internal class Ilce [Table("ilce")]
public class Ilce
{ {
public Ilce()
{
il = new HashSet<Salon>();
}
[Key] [Key]
public int id { get; set; } public int id { get; set; }
@@ -20,10 +18,10 @@ namespace DugunSalonu.Models
[MaxLength(50)] [MaxLength(50)]
public required string adi { get; set; } public required string adi { get; set; }
[Required] [Required]
public required int ilid { get; set; } [Column("ilid")]
ICollection<Salon>? il { get; set; } public required int ILid { get; set; }
Salon? il { get; set; }
ICollection<Salon>? ilce { get; set; } ICollection<Salon>? salon { get; set; }
public Il? Il { get; set; }
} }
} }

View File

@@ -8,7 +8,7 @@ using System.Threading.Tasks;
namespace DugunSalonu.Models namespace DugunSalonu.Models
{ {
internal class Kullanici public class Kullanici
{ {
[Key] [Key]
public int id { get; set; } public int id { get; set; }

View File

@@ -9,14 +9,14 @@ using System.Windows.Forms.VisualStyles;
namespace DugunSalonu.Models namespace DugunSalonu.Models
{ {
public class Referans public class Referans
{ {
[Key] [Key]
public int id { get; set; } public int id { get; set; }
[Required] [Required]
[MaxLength(50)] [MaxLength(50)]
public required string turu { get; set; } public required string turu { get; set; }
[Required] [Required]
[MaxLength(20)] [MaxLength(20)]
public required string kodu { get; set; } public required string kodu { get; set; }
@@ -24,7 +24,7 @@ namespace DugunSalonu.Models
[MaxLength(50)] [MaxLength(50)]
public required string adi { get; set; } public required string adi { get; set; }
[Required] [Required]
public required DateTime kts { get; set; } public required DateTime kts { get; set; } = DateTime.UtcNow;
[Required] [Required]
public required int kk { get; set; } public required int kk { get; set; }

View File

@@ -8,12 +8,12 @@ using System.Threading.Tasks;
namespace DugunSalonu.Models namespace DugunSalonu.Models
{ {
internal class dugunsalonuContext:DbContext public class dugunsalonuContext : DbContext
{ {
public DbSet<Kullanici> kullanici { get; set; } public DbSet<Kullanici> kullanici { get; set; }
public DbSet<Salon> salon { get; set; } public DbSet<Salon> salon { get; set; }
public DbSet<Il> il { get; set; } public DbSet<Il> il { get; set; }
public DbSet<Ilce> ilce { get; set; } public DbSet<Ilce> ilce { get; set; }
@@ -26,11 +26,14 @@ namespace DugunSalonu.Models
modelBuilder.Entity<Referans>() modelBuilder.Entity<Referans>()
.HasIndex(r => new { r.turu, r.kodu }) .HasIndex(r => new { r.turu, r.kodu })
.IsUnique(); .IsUnique();
modelBuilder.Entity<Referans>().HasNoKey();
modelBuilder.Entity<Il>().HasMany<Ilce>(i => i.ilceler);
modelBuilder.Entity<Ilce>().HasOne<Il>(i => i.Il);
/*
// kts alanı için default değer // kts alanı için default değer
modelBuilder.Entity<Referans>() modelBuilder.Entity<Referans>()
.Property(r => r.kts) .Property(r => r.kts)
.HasDefaultValueSql("NOW()"); .HasDefaultValueSql("NOW()");*/
} }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{ {
@@ -38,22 +41,6 @@ namespace DugunSalonu.Models
base.OnConfiguring(optionsBuilder); base.OnConfiguring(optionsBuilder);
} }
/*protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
foreach (var entityType in modelBuilder.Model.GetEntityTypes())
{
// Sütun isimlerini büyük harfe dönüştür
foreach (var property in entityType.GetProperties())
{
var columnName = property.GetColumnName(StoreObjectIdentifier.Table(entityType.GetTableName(), entityType.GetSchema()));
// property.SetColumnName(Encoding.ASCII.GetString(columnName.ToLower()));
}
// İsteğe bağlı: Tablo isimlerini de büyük harfe dönüştür (eğer istiyorsanız)
entityType.SetTableName(entityType.GetTableName().ToLower());
}
}*/
} }
} }