This commit is contained in:
Дмитрий Шиманский
2023-12-19 11:57:19 +03:00
parent 4e43b1631b
commit a5d39384ac
34 changed files with 1825 additions and 79 deletions

19
Models/AppDbContext.cs Normal file
View File

@@ -0,0 +1,19 @@
using Microsoft.EntityFrameworkCore;
using yaflay.ru.Models.Tables;
namespace yaflay.ru.Models
{
public class AppDbContext : DbContext
{
public AppDbContext(DbContextOptions<AppDbContext> options) : base(options) {}
public DbSet<Blogs> Blogs { get; set; }
public DbSet<Comments> Comments { get; set; }
public DbSet<Redirects> Redirects { get; set; }
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
}
}
}

26
Models/Tables/Blogs.cs Normal file
View File

@@ -0,0 +1,26 @@
using Microsoft.EntityFrameworkCore;
using System.ComponentModel.DataAnnotations.Schema;
namespace yaflay.ru.Models.Tables
{
[Table("Blogs", Schema = "public")]
public class Blogs
{
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; set; }
public string Title { get; set; }
public string Text { get; set; }
public string Annotation { get; set; }
public string? ImageUrl { get; set; }
public DateTime dateTime { get; set; }
public Author author { get; set; }
}
public class Author
{
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; set; }
public int discordId { get; set; }
public string discordNickName { get; set; }
}
}

17
Models/Tables/Comments.cs Normal file
View File

@@ -0,0 +1,17 @@
using System.ComponentModel.DataAnnotations.Schema;
using System.Net.Mail;
namespace yaflay.ru.Models.Tables
{
[Table("Comments", Schema = "public")]
public class Comments
{
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; set; }
public long dateTime { get; set; }
public string Text { get; set; }
public string creatorMail { get; set; }
public int postId { get; set; }
}
}

View File

@@ -0,0 +1,12 @@
using System.ComponentModel.DataAnnotations.Schema;
namespace yaflay.ru.Models.Tables
{
public class Redirects
{
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; set; }
public string? uri { get; set; }
public string? redirectTo { get; set; }
}
}