Skip to content

Commit

Permalink
Merge pull request #33 from PatrickMatthiesen/code-cleanup-and-format…
Browse files Browse the repository at this point in the history
…ting

code cleanup
  • Loading branch information
PatrickMatthiesen authored Mar 1, 2023
2 parents 59f280a + 841a899 commit 185c4ea
Show file tree
Hide file tree
Showing 50 changed files with 377 additions and 599 deletions.
2 changes: 1 addition & 1 deletion MiniTwit/MiniTwit.sln
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MiniTwit.Client", "MiniTwit
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MiniTwit.Shared", "MiniTwit\Shared\MiniTwit.Shared.csproj", "{13D3B28B-6915-4610-A09E-69AB8450D89C}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Infrastructure", "MiniTwit\Infrastructure\Infrastructure.csproj", "{EE266498-29DE-481B-BB11-5834A576D09C}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MiniTwit.Infrastructure", "MiniTwit\Infrastructure\MiniTwit.Infrastructure.csproj", "{EE266498-29DE-481B-BB11-5834A576D09C}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{21E56AEA-B0B1-4006-861C-370EEF085CD1}"
EndProject
Expand Down
17 changes: 6 additions & 11 deletions MiniTwit/MiniTwit/Infrastructure/DbContext/ApplicationDbContext.cs
Original file line number Diff line number Diff line change
@@ -1,26 +1,21 @@
using Duende.IdentityServer.EntityFramework.Options;
using Duende.IdentityServer.Models;
using Infrastructure.Models;
using Microsoft.AspNetCore.ApiAuthorization.IdentityServer;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Options;
using Microsoft.EntityFrameworkCore.Design;
using Microsoft.Extensions.Configuration;
using MiniTwit.Infrastructure.Models;

namespace Infrastructure.Data;
public class ApplicationDbContext : ApiAuthorizationDbContext<ApplicationUser>
{
namespace MiniTwit.Infrastructure.DbContext;
public class ApplicationDbContext : ApiAuthorizationDbContext<ApplicationUser> {
private DbContextOptions<ApplicationDbContext> options;

public DbSet<Message> Messages => Set<Message>();
public DbSet<ApplicationUser> Users => Set<ApplicationUser>();
public DbSet<Latest> Latests => Set<Latest>();

public ApplicationDbContext(
DbContextOptions options,
IOptions<OperationalStoreOptions> operationalStoreOptions) : base(options, operationalStoreOptions)
{
IOptions<OperationalStoreOptions> operationalStoreOptions) : base(options, operationalStoreOptions) {
}


}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,34 +1,27 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace Infrastructure.Migrations
{
namespace Infrastructure.Migrations {
/// <inheritdoc />
public partial class InitialMigrations : Migration
{
public partial class InitialMigrations : Migration {
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
protected override void Up(MigrationBuilder migrationBuilder) {
migrationBuilder.CreateTable(
name: "AspNetRoles",
columns: table => new
{
columns: table => new {
Id = table.Column<string>(type: "nvarchar(450)", nullable: false),
Name = table.Column<string>(type: "nvarchar(256)", maxLength: 256, nullable: true),
NormalizedName = table.Column<string>(type: "nvarchar(256)", maxLength: 256, nullable: true),
ConcurrencyStamp = table.Column<string>(type: "nvarchar(max)", nullable: true)
},
constraints: table =>
{
constraints: table => {
table.PrimaryKey("PK_AspNetRoles", x => x.Id);
});

migrationBuilder.CreateTable(
name: "AspNetUsers",
columns: table => new
{
columns: table => new {
Id = table.Column<string>(type: "nvarchar(450)", nullable: false),
UserName = table.Column<string>(type: "nvarchar(256)", maxLength: 256, nullable: true),
NormalizedUserName = table.Column<string>(type: "nvarchar(256)", maxLength: 256, nullable: true),
Expand All @@ -45,15 +38,13 @@ protected override void Up(MigrationBuilder migrationBuilder)
LockoutEnabled = table.Column<bool>(type: "bit", nullable: false),
AccessFailedCount = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
constraints: table => {
table.PrimaryKey("PK_AspNetUsers", x => x.Id);
});

migrationBuilder.CreateTable(
name: "DeviceCodes",
columns: table => new
{
columns: table => new {
UserCode = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: false),
DeviceCode = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: false),
SubjectId = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: true),
Expand All @@ -64,15 +55,13 @@ protected override void Up(MigrationBuilder migrationBuilder)
Expiration = table.Column<DateTime>(type: "datetime2", nullable: false),
Data = table.Column<string>(type: "nvarchar(max)", maxLength: 50000, nullable: false)
},
constraints: table =>
{
constraints: table => {
table.PrimaryKey("PK_DeviceCodes", x => x.UserCode);
});

migrationBuilder.CreateTable(
name: "Keys",
columns: table => new
{
columns: table => new {
Id = table.Column<string>(type: "nvarchar(450)", nullable: false),
Version = table.Column<int>(type: "int", nullable: false),
Created = table.Column<DateTime>(type: "datetime2", nullable: false),
Expand All @@ -82,15 +71,13 @@ protected override void Up(MigrationBuilder migrationBuilder)
DataProtected = table.Column<bool>(type: "bit", nullable: false),
Data = table.Column<string>(type: "nvarchar(max)", nullable: false)
},
constraints: table =>
{
constraints: table => {
table.PrimaryKey("PK_Keys", x => x.Id);
});

migrationBuilder.CreateTable(
name: "PersistedGrants",
columns: table => new
{
columns: table => new {
Key = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: false),
Type = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
SubjectId = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: true),
Expand All @@ -102,23 +89,20 @@ protected override void Up(MigrationBuilder migrationBuilder)
ConsumedTime = table.Column<DateTime>(type: "datetime2", nullable: true),
Data = table.Column<string>(type: "nvarchar(max)", maxLength: 50000, nullable: false)
},
constraints: table =>
{
constraints: table => {
table.PrimaryKey("PK_PersistedGrants", x => x.Key);
});

migrationBuilder.CreateTable(
name: "AspNetRoleClaims",
columns: table => new
{
columns: table => new {
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
RoleId = table.Column<string>(type: "nvarchar(450)", nullable: false),
ClaimType = table.Column<string>(type: "nvarchar(max)", nullable: true),
ClaimValue = table.Column<string>(type: "nvarchar(max)", nullable: true)
},
constraints: table =>
{
constraints: table => {
table.PrimaryKey("PK_AspNetRoleClaims", x => x.Id);
table.ForeignKey(
name: "FK_AspNetRoleClaims_AspNetRoles_RoleId",
Expand All @@ -130,16 +114,14 @@ protected override void Up(MigrationBuilder migrationBuilder)

migrationBuilder.CreateTable(
name: "AspNetUserClaims",
columns: table => new
{
columns: table => new {
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
UserId = table.Column<string>(type: "nvarchar(450)", nullable: false),
ClaimType = table.Column<string>(type: "nvarchar(max)", nullable: true),
ClaimValue = table.Column<string>(type: "nvarchar(max)", nullable: true)
},
constraints: table =>
{
constraints: table => {
table.PrimaryKey("PK_AspNetUserClaims", x => x.Id);
table.ForeignKey(
name: "FK_AspNetUserClaims_AspNetUsers_UserId",
Expand All @@ -151,15 +133,13 @@ protected override void Up(MigrationBuilder migrationBuilder)

migrationBuilder.CreateTable(
name: "AspNetUserLogins",
columns: table => new
{
columns: table => new {
LoginProvider = table.Column<string>(type: "nvarchar(128)", maxLength: 128, nullable: false),
ProviderKey = table.Column<string>(type: "nvarchar(128)", maxLength: 128, nullable: false),
ProviderDisplayName = table.Column<string>(type: "nvarchar(max)", nullable: true),
UserId = table.Column<string>(type: "nvarchar(450)", nullable: false)
},
constraints: table =>
{
constraints: table => {
table.PrimaryKey("PK_AspNetUserLogins", x => new { x.LoginProvider, x.ProviderKey });
table.ForeignKey(
name: "FK_AspNetUserLogins_AspNetUsers_UserId",
Expand All @@ -171,13 +151,11 @@ protected override void Up(MigrationBuilder migrationBuilder)

migrationBuilder.CreateTable(
name: "AspNetUserRoles",
columns: table => new
{
columns: table => new {
UserId = table.Column<string>(type: "nvarchar(450)", nullable: false),
RoleId = table.Column<string>(type: "nvarchar(450)", nullable: false)
},
constraints: table =>
{
constraints: table => {
table.PrimaryKey("PK_AspNetUserRoles", x => new { x.UserId, x.RoleId });
table.ForeignKey(
name: "FK_AspNetUserRoles_AspNetRoles_RoleId",
Expand All @@ -195,15 +173,13 @@ protected override void Up(MigrationBuilder migrationBuilder)

migrationBuilder.CreateTable(
name: "AspNetUserTokens",
columns: table => new
{
columns: table => new {
UserId = table.Column<string>(type: "nvarchar(450)", nullable: false),
LoginProvider = table.Column<string>(type: "nvarchar(128)", maxLength: 128, nullable: false),
Name = table.Column<string>(type: "nvarchar(128)", maxLength: 128, nullable: false),
Value = table.Column<string>(type: "nvarchar(max)", nullable: true)
},
constraints: table =>
{
constraints: table => {
table.PrimaryKey("PK_AspNetUserTokens", x => new { x.UserId, x.LoginProvider, x.Name });
table.ForeignKey(
name: "FK_AspNetUserTokens_AspNetUsers_UserId",
Expand Down Expand Up @@ -290,8 +266,7 @@ protected override void Up(MigrationBuilder migrationBuilder)
}

/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
protected override void Down(MigrationBuilder migrationBuilder) {
migrationBuilder.DropTable(
name: "AspNetRoleClaims");

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace Infrastructure.Migrations
{
namespace Infrastructure.Migrations {
/// <inheritdoc />
public partial class ExtendDataModels : Migration
{
public partial class ExtendDataModels : Migration {
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
protected override void Up(MigrationBuilder migrationBuilder) {
migrationBuilder.AddColumn<string>(
name: "ApplicationUserId",
table: "AspNetUsers",
Expand All @@ -19,17 +15,15 @@ protected override void Up(MigrationBuilder migrationBuilder)

migrationBuilder.CreateTable(
name: "Messages",
columns: table => new
{
columns: table => new {
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Text = table.Column<string>(type: "nvarchar(max)", nullable: false),
PubDate = table.Column<DateTime>(type: "datetime2", nullable: false),
AuthorId = table.Column<string>(type: "nvarchar(450)", nullable: true),
Flagged = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
constraints: table => {
table.PrimaryKey("PK_Messages", x => x.Id);
table.ForeignKey(
name: "FK_Messages_AspNetUsers_AuthorId",
Expand Down Expand Up @@ -57,8 +51,7 @@ protected override void Up(MigrationBuilder migrationBuilder)
}

/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
protected override void Down(MigrationBuilder migrationBuilder) {
migrationBuilder.DropForeignKey(
name: "FK_AspNetUsers_AspNetUsers_ApplicationUserId",
table: "AspNetUsers");
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,16 @@

#nullable disable

namespace Infrastructure.Migrations
{
namespace Infrastructure.Migrations {
/// <inheritdoc />
public partial class MessagesToUsers : Migration
{
public partial class MessagesToUsers : Migration {
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
protected override void Up(MigrationBuilder migrationBuilder) {

}

/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
protected override void Down(MigrationBuilder migrationBuilder) {

}
}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 185c4ea

Please sign in to comment.