CleanUp and added migration
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
<Project>
|
<Project>
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net8.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ public interface IApplicationDbContext
|
|||||||
|
|
||||||
DbSet<TodoItem> TodoItems { get; }
|
DbSet<TodoItem> TodoItems { get; }
|
||||||
|
|
||||||
DbSet<FuturCreator> FuturCreator { get; }
|
DbSet<FuturCreator> FuturCreators { get; }
|
||||||
|
|
||||||
Task<int> SaveChangesAsync(CancellationToken cancellationToken);
|
Task<int> SaveChangesAsync(CancellationToken cancellationToken);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using Hutopy.Application.Common.Interfaces;
|
using Hutopy.Application.Common.Interfaces;
|
||||||
|
using Hutopy.Domain.Entities;
|
||||||
|
|
||||||
namespace Hutopy.Application.TodoItems.Commands.CreateFuturCreator;
|
namespace Hutopy.Application.FuturCreators.Commands.CreateFuturCreator;
|
||||||
|
|
||||||
public record CreateFuturCreatorCommand : IRequest<int>
|
public record CreateFuturCreatorCommand : IRequest<int>
|
||||||
{
|
{
|
||||||
@@ -34,7 +35,7 @@ public class CreateFuturCreatorCommandHandler : IRequestHandler<CreateFuturCreat
|
|||||||
ReasonToJoin = request.ReasonToJoin,
|
ReasonToJoin = request.ReasonToJoin,
|
||||||
};
|
};
|
||||||
|
|
||||||
_context.FuturCreator.Add(entity);
|
_context.FuturCreators.Add(entity);
|
||||||
|
|
||||||
await _context.SaveChangesAsync(cancellationToken);
|
await _context.SaveChangesAsync(cancellationToken);
|
||||||
|
|
||||||
@@ -1,3 +1,5 @@
|
|||||||
|
namespace Hutopy.Domain.Entities;
|
||||||
|
|
||||||
public class FuturCreator : BaseAuditableEntity
|
public class FuturCreator : BaseAuditableEntity
|
||||||
{
|
{
|
||||||
public required string FirstName { get; set; }
|
public required string FirstName { get; set; }
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ public class ApplicationDbContext : IdentityDbContext<ApplicationUser>, IApplica
|
|||||||
|
|
||||||
public DbSet<TodoItem> TodoItems => Set<TodoItem>();
|
public DbSet<TodoItem> TodoItems => Set<TodoItem>();
|
||||||
|
|
||||||
public DbSet<FuturCreator> FuturCreator => Set<FuturCreator>();
|
public DbSet<FuturCreator> FuturCreators => Set<FuturCreator>();
|
||||||
|
|
||||||
protected override void OnModelCreating(ModelBuilder builder)
|
protected override void OnModelCreating(ModelBuilder builder)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -12,8 +12,8 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
|||||||
namespace Hutopy.Infrastructure.Data.Migrations
|
namespace Hutopy.Infrastructure.Data.Migrations
|
||||||
{
|
{
|
||||||
[DbContext(typeof(ApplicationDbContext))]
|
[DbContext(typeof(ApplicationDbContext))]
|
||||||
[Migration("20240317201728_AddFuturCreator")]
|
[Migration("20240317201728_AddFuturCreators")]
|
||||||
partial class AddFuturCreator
|
partial class AddfuturCreators
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||||
@@ -25,7 +25,7 @@ namespace Hutopy.Infrastructure.Data.Migrations
|
|||||||
|
|
||||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||||
|
|
||||||
modelBuilder.Entity("FuturCreator", b =>
|
modelBuilder.Entity("FuturCreators", b =>
|
||||||
{
|
{
|
||||||
b.Property<int>("Id")
|
b.Property<int>("Id")
|
||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
@@ -71,7 +71,7 @@ namespace Hutopy.Infrastructure.Data.Migrations
|
|||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
|
|
||||||
b.ToTable("FuturCreator");
|
b.ToTable("FuturCreators");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("Hutopy.Domain.Entities.TodoItem", b =>
|
modelBuilder.Entity("Hutopy.Domain.Entities.TodoItem", b =>
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ using Microsoft.EntityFrameworkCore.Migrations;
|
|||||||
namespace Hutopy.Infrastructure.Data.Migrations
|
namespace Hutopy.Infrastructure.Data.Migrations
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public partial class AddFuturCreator : Migration
|
public partial class AddFuturCreators : Migration
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
@@ -48,7 +48,7 @@ namespace Hutopy.Infrastructure.Data.Migrations
|
|||||||
oldMaxLength: 128);
|
oldMaxLength: 128);
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
migrationBuilder.CreateTable(
|
||||||
name: "FuturCreator",
|
name: "FuturCreators",
|
||||||
columns: table => new
|
columns: table => new
|
||||||
{
|
{
|
||||||
Id = table.Column<int>(type: "int", nullable: false)
|
Id = table.Column<int>(type: "int", nullable: false)
|
||||||
@@ -66,7 +66,7 @@ namespace Hutopy.Infrastructure.Data.Migrations
|
|||||||
},
|
},
|
||||||
constraints: table =>
|
constraints: table =>
|
||||||
{
|
{
|
||||||
table.PrimaryKey("PK_FuturCreator", x => x.Id);
|
table.PrimaryKey("PK_FuturCreators", x => x.Id);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -74,7 +74,7 @@ namespace Hutopy.Infrastructure.Data.Migrations
|
|||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
{
|
{
|
||||||
migrationBuilder.DropTable(
|
migrationBuilder.DropTable(
|
||||||
name: "FuturCreator");
|
name: "FuturCreators");
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<string>(
|
migrationBuilder.AlterColumn<string>(
|
||||||
name: "Name",
|
name: "Name",
|
||||||
|
|||||||
18
src/Web/Endpoints/FuturCreators.cs
Normal file
18
src/Web/Endpoints/FuturCreators.cs
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
using Hutopy.Application.FuturCreators.Commands.CreateFuturCreator;
|
||||||
|
|
||||||
|
namespace Hutopy.Web.Endpoints;
|
||||||
|
|
||||||
|
public class FuturCreators : EndpointGroupBase
|
||||||
|
{
|
||||||
|
public override void Map(WebApplication app)
|
||||||
|
{
|
||||||
|
app.MapGroup(this)
|
||||||
|
.RequireAuthorization()
|
||||||
|
.MapPost(CreateFuturCreator);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Task<int> CreateFuturCreator(ISender sender, CreateFuturCreatorCommand command)
|
||||||
|
{
|
||||||
|
return sender.Send(command);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,6 +6,44 @@
|
|||||||
"version": "1.0.0"
|
"version": "1.0.0"
|
||||||
},
|
},
|
||||||
"paths": {
|
"paths": {
|
||||||
|
"/api/FuturCreators": {
|
||||||
|
"post": {
|
||||||
|
"tags": [
|
||||||
|
"FuturCreators"
|
||||||
|
],
|
||||||
|
"operationId": "CreateFuturCreator",
|
||||||
|
"requestBody": {
|
||||||
|
"x-name": "command",
|
||||||
|
"content": {
|
||||||
|
"application/json": {
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/components/schemas/CreateFuturCreatorCommand"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": true,
|
||||||
|
"x-position": 1
|
||||||
|
},
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "",
|
||||||
|
"content": {
|
||||||
|
"application/json": {
|
||||||
|
"schema": {
|
||||||
|
"type": "integer",
|
||||||
|
"format": "int32"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"security": [
|
||||||
|
{
|
||||||
|
"JWT": []
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
"/api/TodoItems": {
|
"/api/TodoItems": {
|
||||||
"get": {
|
"get": {
|
||||||
"tags": [
|
"tags": [
|
||||||
@@ -757,6 +795,30 @@
|
|||||||
},
|
},
|
||||||
"components": {
|
"components": {
|
||||||
"schemas": {
|
"schemas": {
|
||||||
|
"CreateFuturCreatorCommand": {
|
||||||
|
"type": "object",
|
||||||
|
"additionalProperties": false,
|
||||||
|
"properties": {
|
||||||
|
"firstName": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"lastName": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"emailAddress": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"phoneNumber": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"socialNetworkAccount": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"reasonToJoin": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"PaginatedListOfTodoItemBriefDto": {
|
"PaginatedListOfTodoItemBriefDto": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"additionalProperties": false,
|
"additionalProperties": false,
|
||||||
|
|||||||
Reference in New Issue
Block a user