Commit 4c906beb authored by SergeevaAA's avatar SergeevaAA

Исправлены основные классы, миграции, добавлены методы для хэширования

parent e0eeec0e
......@@ -6,6 +6,7 @@
<ItemGroup>
<Folder Include="Migrations\" />
<Folder Include="Repository\" />
</ItemGroup>
<ItemGroup>
......
// <auto-generated />
using System;
using FileDesk.DataAccess.Repository;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
namespace FileDesk.DataAccess.Migrations
{
[DbContext(typeof(FileDeskContext))]
[Migration("20201023144738_FilesAndDownloadsTablesCreate")]
partial class FilesAndDownloadsTablesCreate
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "3.1.9")
.HasAnnotation("Relational:MaxIdentifierLength", 128)
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
modelBuilder.Entity("FileDesk.Domain.Models.Download", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b.Property<DateTime>("DateTime")
.HasColumnType("datetime2");
b.Property<long>("FileId")
.HasColumnType("bigint");
b.Property<string>("IpAddress")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.HasIndex("FileId");
b.ToTable("Downloads");
});
modelBuilder.Entity("FileDesk.Domain.Models.File", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b.Property<byte[]>("Content")
.IsRequired()
.HasColumnType("varbinary(max)");
b.Property<string>("Description")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int>("Format")
.HasColumnType("int");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<DateTime>("UploadDateTime")
.HasColumnType("datetime2");
b.HasKey("Id");
b.ToTable("Files");
});
modelBuilder.Entity("FileDesk.Domain.Models.Download", b =>
{
b.HasOne("FileDesk.Domain.Models.File", "File")
.WithMany("Downloads")
.HasForeignKey("FileId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
#pragma warning restore 612, 618
}
}
}
using System;
using Microsoft.EntityFrameworkCore.Migrations;
namespace FileDesk.DataAccess.Migrations
{
public partial class FilesAndDownloadsTablesCreate : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Files",
columns: table => new
{
Id = table.Column<long>(nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Name = table.Column<string>(nullable: false),
Description = table.Column<string>(nullable: false),
UploadDateTime = table.Column<DateTime>(nullable: false),
Content = table.Column<byte[]>(nullable: false),
Format = table.Column<int>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Files", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Downloads",
columns: table => new
{
Id = table.Column<long>(nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
FileId = table.Column<long>(nullable: false),
DateTime = table.Column<DateTime>(nullable: false),
IpAddress = table.Column<string>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Downloads", x => x.Id);
table.ForeignKey(
name: "FK_Downloads_Files_FileId",
column: x => x.FileId,
principalTable: "Files",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_Downloads_FileId",
table: "Downloads",
column: "FileId");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Downloads");
migrationBuilder.DropTable(
name: "Files");
}
}
}
\ No newline at end of file
// <auto-generated />
using System;
using FileDesk.DataAccess.Repository;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace FileDesk.DataAccess.Migrations
{
[DbContext(typeof(FileDeskContext))]
[Migration("20201026142647_InitialMigration")]
partial class InitialMigration
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "3.1.9")
.HasAnnotation("Relational:MaxIdentifierLength", 128)
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
modelBuilder.Entity("FileDesk.Domain.Models.Action", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b.Property<int>("ActionType")
.HasColumnType("int");
b.Property<DateTime>("DateTime")
.HasColumnType("datetime2");
b.Property<long>("FileId")
.HasColumnType("bigint");
b.Property<long>("UserId")
.HasColumnType("bigint");
b.HasKey("Id");
b.HasIndex("FileId");
b.HasIndex("UserId");
b.ToTable("Actions");
});
modelBuilder.Entity("FileDesk.Domain.Models.Contact", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b.Property<string>("Department")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Email")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("FirstName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("LastName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("MiddleName")
.HasColumnType("nvarchar(max)");
b.Property<string>("Organization")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Phone")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Post")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Contacts");
b.HasData(
new
{
Id = 1L,
Department = "ИШИТР",
Email = "aas189@tpu.ru",
FirstName = "Анастасия",
LastName = "Сергеева",
MiddleName = "Анатольевна",
Organization = "ТПУ",
Phone = "+7(987)654-32-10",
Post = "Студент группы 8ИМ91"
});
});
modelBuilder.Entity("FileDesk.Domain.Models.File", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b.Property<byte[]>("Content")
.IsRequired()
.HasColumnType("varbinary(max)");
b.Property<string>("Description")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int>("Format")
.HasColumnType("int");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<DateTime>("UploadDateTime")
.HasColumnType("datetime2");
b.Property<long>("UserId")
.HasColumnType("bigint");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("Files");
});
modelBuilder.Entity("FileDesk.Domain.Models.Role", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(450)");
b.HasKey("Id");
b.HasIndex("Name")
.IsUnique();
b.ToTable("Roles");
b.HasData(
new
{
Id = 1L,
Name = "admin"
},
new
{
Id = 2L,
Name = "user"
});
});
modelBuilder.Entity("FileDesk.Domain.Models.User", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b.Property<string>("Login")
.IsRequired()
.HasColumnType("nvarchar(450)");
b.Property<string>("Password")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.HasIndex("Login")
.IsUnique();
b.ToTable("Users");
b.HasData(
new
{
Id = 1L,
Login = "admin",
Password = "5EBE2294ECD0E0F08EAB7690D2A6EE69"
},
new
{
Id = 2L,
Login = "user",
Password = "93AB957B29BBD2564F1850110F29120D"
});
});
modelBuilder.Entity("FileDesk.Domain.Models.UserRole", b =>
{
b.Property<long>("UserId")
.HasColumnType("bigint");
b.Property<long>("RoleId")
.HasColumnType("bigint");
b.HasKey("UserId", "RoleId");
b.HasIndex("RoleId");
b.ToTable("UserRoles");
b.HasData(
new
{
UserId = 1L,
RoleId = 1L
},
new
{
UserId = 1L,
RoleId = 2L
},
new
{
UserId = 2L,
RoleId = 2L
});
});
modelBuilder.Entity("FileDesk.Domain.Models.Action", b =>
{
b.HasOne("FileDesk.Domain.Models.File", "File")
.WithMany()
.HasForeignKey("FileId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("FileDesk.Domain.Models.User", "User")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("FileDesk.Domain.Models.File", b =>
{
b.HasOne("FileDesk.Domain.Models.User", "User")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("FileDesk.Domain.Models.UserRole", b =>
{
b.HasOne("FileDesk.Domain.Models.Role", "Role")
.WithMany("UserRoles")
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("FileDesk.Domain.Models.User", "User")
.WithMany("UserRoles")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
#pragma warning restore 612, 618
}
}
}
using System;
using Microsoft.EntityFrameworkCore.Migrations;
namespace FileDesk.DataAccess.Migrations
{
public partial class InitialMigration : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Contacts",
columns: table => new
{
Id = table.Column<long>(nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
FirstName = table.Column<string>(nullable: false),
MiddleName = table.Column<string>(nullable: true),
LastName = table.Column<string>(nullable: false),
Organization = table.Column<string>(nullable: false),
Department = table.Column<string>(nullable: false),
Post = table.Column<string>(nullable: false),
Email = table.Column<string>(nullable: false),
Phone = table.Column<string>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Contacts", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Roles",
columns: table => new
{
Id = table.Column<long>(nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Name = table.Column<string>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Roles", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Users",
columns: table => new
{
Id = table.Column<long>(nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Login = table.Column<string>(nullable: false),
Password = table.Column<string>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Users", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Files",
columns: table => new
{
Id = table.Column<long>(nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Name = table.Column<string>(nullable: false),
Description = table.Column<string>(nullable: false),
UploadDateTime = table.Column<DateTime>(nullable: false),
Content = table.Column<byte[]>(nullable: false),
Format = table.Column<int>(nullable: false),
UserId = table.Column<long>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Files", x => x.Id);
table.ForeignKey(
name: "FK_Files_Users_UserId",
column: x => x.UserId,
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.NoAction);
});
migrationBuilder.CreateTable(
name: "UserRoles",
columns: table => new
{
UserId = table.Column<long>(nullable: false),
RoleId = table.Column<long>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_UserRoles", x => new { x.UserId, x.RoleId });
table.ForeignKey(
name: "FK_UserRoles_Roles_RoleId",
column: x => x.RoleId,
principalTable: "Roles",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_UserRoles_Users_UserId",
column: x => x.UserId,
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Actions",
columns: table => new
{
Id = table.Column<long>(nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
FileId = table.Column<long>(nullable: false),
UserId = table.Column<long>(nullable: false),
DateTime = table.Column<DateTime>(nullable: false),
ActionType = table.Column<int>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Actions", x => x.Id);