ilk commit
This commit is contained in:
31
src/DownloadManager.Core/Data/AppDbContext.cs
Normal file
31
src/DownloadManager.Core/Data/AppDbContext.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using DownloadManager.Core.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace DownloadManager.Core.Data;
|
||||
|
||||
public class AppDbContext : DbContext
|
||||
{
|
||||
public AppDbContext(DbContextOptions<AppDbContext> options) : base(options)
|
||||
{
|
||||
}
|
||||
|
||||
public DbSet<DownloadItem> Downloads { get; set; } = null!;
|
||||
public DbSet<DownloadSegment> Segments { get; set; } = null!;
|
||||
public DbSet<DownloadCategory> Categories { get; set; } = null!;
|
||||
public DbSet<GrabberProject> GrabberProjects { get; set; } = null!;
|
||||
public DbSet<ScheduleJob> ScheduleJobs { get; set; } = null!;
|
||||
public DbSet<AppSetting> Settings { get; set; } = null!;
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder b)
|
||||
{
|
||||
// Seed — varsayılan kategoriler
|
||||
b.Entity<DownloadCategory>().HasData(
|
||||
new DownloadCategory { Id = 1, Name = "Yazılım", SavePath = @"%USERPROFILE%\Downloads\Yazılım", Extensions = "exe,msi,dmg" },
|
||||
new DownloadCategory { Id = 2, Name = "Belge", SavePath = @"%USERPROFILE%\Downloads\Belgeler", Extensions = "pdf,docx,xlsx,pptx" },
|
||||
new DownloadCategory { Id = 3, Name = "Ses", SavePath = @"%USERPROFILE%\Downloads\Ses", Extensions = "mp3,flac,wav,aac" },
|
||||
new DownloadCategory { Id = 4, Name = "Video", SavePath = @"%USERPROFILE%\Downloads\Video", Extensions = "mp4,mkv,avi,mov" },
|
||||
new DownloadCategory { Id = 5, Name = "Görsel", SavePath = @"%USERPROFILE%\Downloads\Görseller",Extensions = "jpg,jpeg,png,gif,webp" },
|
||||
new DownloadCategory { Id = 6, Name = "Diğer", SavePath = @"%USERPROFILE%\Downloads", Extensions = "" }
|
||||
);
|
||||
}
|
||||
}
|
||||
15
src/DownloadManager.Core/Data/AppDbContextFactory.cs
Normal file
15
src/DownloadManager.Core/Data/AppDbContextFactory.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Design;
|
||||
|
||||
namespace DownloadManager.Core.Data;
|
||||
|
||||
public class AppDbContextFactory : IDesignTimeDbContextFactory<AppDbContext>
|
||||
{
|
||||
public AppDbContext CreateDbContext(string[] args)
|
||||
{
|
||||
var optionsBuilder = new DbContextOptionsBuilder<AppDbContext>();
|
||||
optionsBuilder.UseSqlite("Data Source=downloadmanager.db");
|
||||
|
||||
return new AppDbContext(optionsBuilder.Options);
|
||||
}
|
||||
}
|
||||
264
src/DownloadManager.Core/Data/Migrations/20260501194147_InitialCreate.Designer.cs
generated
Normal file
264
src/DownloadManager.Core/Data/Migrations/20260501194147_InitialCreate.Designer.cs
generated
Normal file
@@ -0,0 +1,264 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using DownloadManager.Core.Data;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace DownloadManager.Core.Data.Migrations
|
||||
{
|
||||
[DbContext(typeof(AppDbContext))]
|
||||
[Migration("20260501194147_InitialCreate")]
|
||||
partial class InitialCreate
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder.HasAnnotation("ProductVersion", "8.0.26");
|
||||
|
||||
modelBuilder.Entity("DownloadManager.Core.Models.AppSetting", b =>
|
||||
{
|
||||
b.Property<string>("Key")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Value")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("Key");
|
||||
|
||||
b.ToTable("Settings");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DownloadManager.Core.Models.DownloadCategory", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("Extensions")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("SavePath")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Categories");
|
||||
|
||||
b.HasData(
|
||||
new
|
||||
{
|
||||
Id = 1,
|
||||
Extensions = "exe,msi,dmg",
|
||||
Name = "Yazılım",
|
||||
SavePath = "%USERPROFILE%\\Downloads\\Yazılım"
|
||||
},
|
||||
new
|
||||
{
|
||||
Id = 2,
|
||||
Extensions = "pdf,docx,xlsx,pptx",
|
||||
Name = "Belge",
|
||||
SavePath = "%USERPROFILE%\\Downloads\\Belgeler"
|
||||
},
|
||||
new
|
||||
{
|
||||
Id = 3,
|
||||
Extensions = "mp3,flac,wav,aac",
|
||||
Name = "Ses",
|
||||
SavePath = "%USERPROFILE%\\Downloads\\Ses"
|
||||
},
|
||||
new
|
||||
{
|
||||
Id = 4,
|
||||
Extensions = "mp4,mkv,avi,mov",
|
||||
Name = "Video",
|
||||
SavePath = "%USERPROFILE%\\Downloads\\Video"
|
||||
},
|
||||
new
|
||||
{
|
||||
Id = 5,
|
||||
Extensions = "jpg,jpeg,png,gif,webp",
|
||||
Name = "Görsel",
|
||||
SavePath = "%USERPROFILE%\\Downloads\\Görseller"
|
||||
},
|
||||
new
|
||||
{
|
||||
Id = 6,
|
||||
Extensions = "",
|
||||
Name = "Diğer",
|
||||
SavePath = "%USERPROFILE%\\Downloads"
|
||||
});
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DownloadManager.Core.Models.DownloadItem", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<int>("CategoryId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<DateTime?>("CompletedAt")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<DateTime>("CreatedAt")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<long>("DownloadedBytes")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("ETag")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("ErrorMessage")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("FileName")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("LastModified")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("PasswordHash")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<int>("Priority")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("Referrer")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("SavePath")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<int>("SegmentCount")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("Sha256Checksum")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<DateTime?>("StartedAt")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<int>("Status")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<long>("TotalSize")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("Url")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("UserAgent")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Username")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("CategoryId");
|
||||
|
||||
b.ToTable("Downloads");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DownloadManager.Core.Models.DownloadSegment", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<Guid>("DownloadItemId")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<long>("Downloaded")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<long>("EndByte")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int>("Index")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<long>("StartByte")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int>("Status")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("TempFilePath")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("DownloadItemId");
|
||||
|
||||
b.ToTable("Segments");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DownloadManager.Core.Models.GrabberProject", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("GrabberProjects");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DownloadManager.Core.Models.ScheduleJob", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("ScheduleJobs");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DownloadManager.Core.Models.DownloadItem", b =>
|
||||
{
|
||||
b.HasOne("DownloadManager.Core.Models.DownloadCategory", "Category")
|
||||
.WithMany()
|
||||
.HasForeignKey("CategoryId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Category");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DownloadManager.Core.Models.DownloadSegment", b =>
|
||||
{
|
||||
b.HasOne("DownloadManager.Core.Models.DownloadItem", null)
|
||||
.WithMany("Segments")
|
||||
.HasForeignKey("DownloadItemId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DownloadManager.Core.Models.DownloadItem", b =>
|
||||
{
|
||||
b.Navigation("Segments");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,175 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional
|
||||
|
||||
namespace DownloadManager.Core.Data.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class InitialCreate : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Categories",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "INTEGER", nullable: false)
|
||||
.Annotation("Sqlite:Autoincrement", true),
|
||||
Name = table.Column<string>(type: "TEXT", nullable: false),
|
||||
SavePath = table.Column<string>(type: "TEXT", nullable: false),
|
||||
Extensions = table.Column<string>(type: "TEXT", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Categories", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "GrabberProjects",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "INTEGER", nullable: false)
|
||||
.Annotation("Sqlite:Autoincrement", true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_GrabberProjects", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "ScheduleJobs",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "INTEGER", nullable: false)
|
||||
.Annotation("Sqlite:Autoincrement", true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_ScheduleJobs", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Settings",
|
||||
columns: table => new
|
||||
{
|
||||
Key = table.Column<string>(type: "TEXT", nullable: false),
|
||||
Value = table.Column<string>(type: "TEXT", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Settings", x => x.Key);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Downloads",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<Guid>(type: "TEXT", nullable: false),
|
||||
Url = table.Column<string>(type: "TEXT", nullable: false),
|
||||
FileName = table.Column<string>(type: "TEXT", nullable: false),
|
||||
SavePath = table.Column<string>(type: "TEXT", nullable: false),
|
||||
CategoryId = table.Column<int>(type: "INTEGER", nullable: false),
|
||||
Status = table.Column<int>(type: "INTEGER", nullable: false),
|
||||
TotalSize = table.Column<long>(type: "INTEGER", nullable: false),
|
||||
DownloadedBytes = table.Column<long>(type: "INTEGER", nullable: false),
|
||||
SegmentCount = table.Column<int>(type: "INTEGER", nullable: false),
|
||||
Priority = table.Column<int>(type: "INTEGER", nullable: false),
|
||||
Referrer = table.Column<string>(type: "TEXT", nullable: true),
|
||||
UserAgent = table.Column<string>(type: "TEXT", nullable: true),
|
||||
Username = table.Column<string>(type: "TEXT", nullable: true),
|
||||
PasswordHash = table.Column<string>(type: "TEXT", nullable: true),
|
||||
ETag = table.Column<string>(type: "TEXT", nullable: true),
|
||||
LastModified = table.Column<string>(type: "TEXT", nullable: true),
|
||||
ErrorMessage = table.Column<string>(type: "TEXT", nullable: true),
|
||||
Sha256Checksum = table.Column<string>(type: "TEXT", nullable: true),
|
||||
CreatedAt = table.Column<DateTime>(type: "TEXT", nullable: false),
|
||||
StartedAt = table.Column<DateTime>(type: "TEXT", nullable: true),
|
||||
CompletedAt = table.Column<DateTime>(type: "TEXT", nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Downloads", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Downloads_Categories_CategoryId",
|
||||
column: x => x.CategoryId,
|
||||
principalTable: "Categories",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Segments",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "INTEGER", nullable: false)
|
||||
.Annotation("Sqlite:Autoincrement", true),
|
||||
DownloadItemId = table.Column<Guid>(type: "TEXT", nullable: false),
|
||||
Index = table.Column<int>(type: "INTEGER", nullable: false),
|
||||
StartByte = table.Column<long>(type: "INTEGER", nullable: false),
|
||||
EndByte = table.Column<long>(type: "INTEGER", nullable: false),
|
||||
Downloaded = table.Column<long>(type: "INTEGER", nullable: false),
|
||||
Status = table.Column<int>(type: "INTEGER", nullable: false),
|
||||
TempFilePath = table.Column<string>(type: "TEXT", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Segments", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Segments_Downloads_DownloadItemId",
|
||||
column: x => x.DownloadItemId,
|
||||
principalTable: "Downloads",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.InsertData(
|
||||
table: "Categories",
|
||||
columns: new[] { "Id", "Extensions", "Name", "SavePath" },
|
||||
values: new object[,]
|
||||
{
|
||||
{ 1, "exe,msi,dmg", "Yazılım", "%USERPROFILE%\\Downloads\\Yazılım" },
|
||||
{ 2, "pdf,docx,xlsx,pptx", "Belge", "%USERPROFILE%\\Downloads\\Belgeler" },
|
||||
{ 3, "mp3,flac,wav,aac", "Ses", "%USERPROFILE%\\Downloads\\Ses" },
|
||||
{ 4, "mp4,mkv,avi,mov", "Video", "%USERPROFILE%\\Downloads\\Video" },
|
||||
{ 5, "jpg,jpeg,png,gif,webp", "Görsel", "%USERPROFILE%\\Downloads\\Görseller" },
|
||||
{ 6, "", "Diğer", "%USERPROFILE%\\Downloads" }
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Downloads_CategoryId",
|
||||
table: "Downloads",
|
||||
column: "CategoryId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Segments_DownloadItemId",
|
||||
table: "Segments",
|
||||
column: "DownloadItemId");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "GrabberProjects");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "ScheduleJobs");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Segments");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Settings");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Downloads");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Categories");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,261 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using DownloadManager.Core.Data;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace DownloadManager.Core.Data.Migrations
|
||||
{
|
||||
[DbContext(typeof(AppDbContext))]
|
||||
partial class AppDbContextModelSnapshot : ModelSnapshot
|
||||
{
|
||||
protected override void BuildModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder.HasAnnotation("ProductVersion", "8.0.26");
|
||||
|
||||
modelBuilder.Entity("DownloadManager.Core.Models.AppSetting", b =>
|
||||
{
|
||||
b.Property<string>("Key")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Value")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("Key");
|
||||
|
||||
b.ToTable("Settings");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DownloadManager.Core.Models.DownloadCategory", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("Extensions")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("SavePath")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Categories");
|
||||
|
||||
b.HasData(
|
||||
new
|
||||
{
|
||||
Id = 1,
|
||||
Extensions = "exe,msi,dmg",
|
||||
Name = "Yazılım",
|
||||
SavePath = "%USERPROFILE%\\Downloads\\Yazılım"
|
||||
},
|
||||
new
|
||||
{
|
||||
Id = 2,
|
||||
Extensions = "pdf,docx,xlsx,pptx",
|
||||
Name = "Belge",
|
||||
SavePath = "%USERPROFILE%\\Downloads\\Belgeler"
|
||||
},
|
||||
new
|
||||
{
|
||||
Id = 3,
|
||||
Extensions = "mp3,flac,wav,aac",
|
||||
Name = "Ses",
|
||||
SavePath = "%USERPROFILE%\\Downloads\\Ses"
|
||||
},
|
||||
new
|
||||
{
|
||||
Id = 4,
|
||||
Extensions = "mp4,mkv,avi,mov",
|
||||
Name = "Video",
|
||||
SavePath = "%USERPROFILE%\\Downloads\\Video"
|
||||
},
|
||||
new
|
||||
{
|
||||
Id = 5,
|
||||
Extensions = "jpg,jpeg,png,gif,webp",
|
||||
Name = "Görsel",
|
||||
SavePath = "%USERPROFILE%\\Downloads\\Görseller"
|
||||
},
|
||||
new
|
||||
{
|
||||
Id = 6,
|
||||
Extensions = "",
|
||||
Name = "Diğer",
|
||||
SavePath = "%USERPROFILE%\\Downloads"
|
||||
});
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DownloadManager.Core.Models.DownloadItem", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<int>("CategoryId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<DateTime?>("CompletedAt")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<DateTime>("CreatedAt")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<long>("DownloadedBytes")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("ETag")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("ErrorMessage")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("FileName")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("LastModified")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("PasswordHash")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<int>("Priority")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("Referrer")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("SavePath")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<int>("SegmentCount")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("Sha256Checksum")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<DateTime?>("StartedAt")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<int>("Status")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<long>("TotalSize")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("Url")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("UserAgent")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Username")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("CategoryId");
|
||||
|
||||
b.ToTable("Downloads");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DownloadManager.Core.Models.DownloadSegment", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<Guid>("DownloadItemId")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<long>("Downloaded")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<long>("EndByte")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int>("Index")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<long>("StartByte")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int>("Status")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("TempFilePath")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("DownloadItemId");
|
||||
|
||||
b.ToTable("Segments");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DownloadManager.Core.Models.GrabberProject", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("GrabberProjects");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DownloadManager.Core.Models.ScheduleJob", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("ScheduleJobs");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DownloadManager.Core.Models.DownloadItem", b =>
|
||||
{
|
||||
b.HasOne("DownloadManager.Core.Models.DownloadCategory", "Category")
|
||||
.WithMany()
|
||||
.HasForeignKey("CategoryId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Category");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DownloadManager.Core.Models.DownloadSegment", b =>
|
||||
{
|
||||
b.HasOne("DownloadManager.Core.Models.DownloadItem", null)
|
||||
.WithMany("Segments")
|
||||
.HasForeignKey("DownloadItemId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DownloadManager.Core.Models.DownloadItem", b =>
|
||||
{
|
||||
b.Navigation("Segments");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
using DownloadManager.Core.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DownloadManager.Core.Data.Repositories;
|
||||
|
||||
public class CategoryRepository : ICategoryRepository
|
||||
{
|
||||
private readonly AppDbContext _db;
|
||||
public CategoryRepository(AppDbContext db) => _db = db;
|
||||
|
||||
public async Task<IEnumerable<DownloadCategory>> GetAllAsync()
|
||||
=> await _db.Categories.ToListAsync();
|
||||
|
||||
public async Task<DownloadCategory?> GetByIdAsync(int id)
|
||||
=> await _db.Categories.FindAsync(id);
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
using DownloadManager.Core.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DownloadManager.Core.Data.Repositories;
|
||||
|
||||
public class DownloadRepository : IDownloadRepository
|
||||
{
|
||||
private readonly AppDbContext _db;
|
||||
public DownloadRepository(AppDbContext db) => _db = db;
|
||||
|
||||
public async Task<DownloadItem?> GetByIdAsync(Guid id)
|
||||
=> await _db.Downloads.Include(d => d.Segments).FirstOrDefaultAsync(d => d.Id == id);
|
||||
|
||||
public async Task<IEnumerable<DownloadItem>> GetAllAsync()
|
||||
=> await _db.Downloads.Include(d => d.Category).ToListAsync();
|
||||
|
||||
public async Task AddAsync(DownloadItem item)
|
||||
{
|
||||
await _db.Downloads.AddAsync(item);
|
||||
await _db.SaveChangesAsync();
|
||||
}
|
||||
|
||||
public async Task UpdateAsync(DownloadItem item)
|
||||
{
|
||||
_db.Downloads.Update(item);
|
||||
await _db.SaveChangesAsync();
|
||||
}
|
||||
|
||||
public async Task DeleteAsync(Guid id)
|
||||
{
|
||||
var item = await _db.Downloads.FindAsync(id);
|
||||
if (item != null)
|
||||
{
|
||||
_db.Downloads.Remove(item);
|
||||
await _db.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
27
src/DownloadManager.Core/Data/Repositories/IRepositories.cs
Normal file
27
src/DownloadManager.Core/Data/Repositories/IRepositories.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
using DownloadManager.Core.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DownloadManager.Core.Data.Repositories;
|
||||
|
||||
public interface IDownloadRepository
|
||||
{
|
||||
Task<DownloadItem?> GetByIdAsync(Guid id);
|
||||
Task<IEnumerable<DownloadItem>> GetAllAsync();
|
||||
Task AddAsync(DownloadItem item);
|
||||
Task UpdateAsync(DownloadItem item);
|
||||
Task DeleteAsync(Guid id);
|
||||
}
|
||||
|
||||
public interface ICategoryRepository
|
||||
{
|
||||
Task<IEnumerable<DownloadCategory>> GetAllAsync();
|
||||
Task<DownloadCategory?> GetByIdAsync(int id);
|
||||
}
|
||||
|
||||
public interface ISettingsRepository
|
||||
{
|
||||
Task<string?> GetValueAsync(string key);
|
||||
Task SetValueAsync(string key, string value);
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
using DownloadManager.Core.Models;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DownloadManager.Core.Data.Repositories;
|
||||
|
||||
public interface IScheduleRepository
|
||||
{
|
||||
Task<IEnumerable<ScheduleJob>> GetAllAsync();
|
||||
Task AddAsync(ScheduleJob job);
|
||||
Task UpdateAsync(ScheduleJob job);
|
||||
Task DeleteAsync(int id);
|
||||
}
|
||||
|
||||
public class ScheduleRepository : IScheduleRepository
|
||||
{
|
||||
private readonly AppDbContext _db;
|
||||
public ScheduleRepository(AppDbContext db) => _db = db;
|
||||
|
||||
public async Task<IEnumerable<ScheduleJob>> GetAllAsync() => await Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions.ToListAsync(_db.ScheduleJobs);
|
||||
|
||||
public async Task AddAsync(ScheduleJob job)
|
||||
{
|
||||
await _db.ScheduleJobs.AddAsync(job);
|
||||
await _db.SaveChangesAsync();
|
||||
}
|
||||
|
||||
public async Task UpdateAsync(ScheduleJob job)
|
||||
{
|
||||
_db.ScheduleJobs.Update(job);
|
||||
await _db.SaveChangesAsync();
|
||||
}
|
||||
|
||||
public async Task DeleteAsync(int id)
|
||||
{
|
||||
var job = await _db.ScheduleJobs.FindAsync(id);
|
||||
if (job != null)
|
||||
{
|
||||
_db.ScheduleJobs.Remove(job);
|
||||
await _db.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
using DownloadManager.Core.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DownloadManager.Core.Data.Repositories;
|
||||
|
||||
public class SettingsRepository : ISettingsRepository
|
||||
{
|
||||
private readonly AppDbContext _db;
|
||||
public SettingsRepository(AppDbContext db) => _db = db;
|
||||
|
||||
public async Task<string?> GetValueAsync(string key)
|
||||
{
|
||||
var setting = await _db.Settings.FindAsync(key);
|
||||
return setting?.Value;
|
||||
}
|
||||
|
||||
public async Task SetValueAsync(string key, string value)
|
||||
{
|
||||
var setting = await _db.Settings.FindAsync(key);
|
||||
if (setting == null)
|
||||
{
|
||||
await _db.Settings.AddAsync(new AppSetting { Key = key, Value = value });
|
||||
}
|
||||
else
|
||||
{
|
||||
setting.Value = value;
|
||||
}
|
||||
await _db.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user