CleanUp and added migration
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
<Project>
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
@@ -8,7 +8,7 @@ public interface IApplicationDbContext
|
||||
|
||||
DbSet<TodoItem> TodoItems { get; }
|
||||
|
||||
DbSet<FuturCreator> FuturCreator { get; }
|
||||
DbSet<FuturCreator> FuturCreators { get; }
|
||||
|
||||
Task<int> SaveChangesAsync(CancellationToken cancellationToken);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
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>
|
||||
{
|
||||
@@ -34,7 +35,7 @@ public class CreateFuturCreatorCommandHandler : IRequestHandler<CreateFuturCreat
|
||||
ReasonToJoin = request.ReasonToJoin,
|
||||
};
|
||||
|
||||
_context.FuturCreator.Add(entity);
|
||||
_context.FuturCreators.Add(entity);
|
||||
|
||||
await _context.SaveChangesAsync(cancellationToken);
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
namespace Hutopy.Domain.Entities;
|
||||
|
||||
public class FuturCreator : BaseAuditableEntity
|
||||
{
|
||||
public required string FirstName { get; set; }
|
||||
|
||||
@@ -16,7 +16,7 @@ public class ApplicationDbContext : IdentityDbContext<ApplicationUser>, IApplica
|
||||
|
||||
public DbSet<TodoItem> TodoItems => Set<TodoItem>();
|
||||
|
||||
public DbSet<FuturCreator> FuturCreator => Set<FuturCreator>();
|
||||
public DbSet<FuturCreator> FuturCreators => Set<FuturCreator>();
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder builder)
|
||||
{
|
||||
|
||||
@@ -12,8 +12,8 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
namespace Hutopy.Infrastructure.Data.Migrations
|
||||
{
|
||||
[DbContext(typeof(ApplicationDbContext))]
|
||||
[Migration("20240317201728_AddFuturCreator")]
|
||||
partial class AddFuturCreator
|
||||
[Migration("20240317201728_AddFuturCreators")]
|
||||
partial class AddfuturCreators
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
@@ -25,7 +25,7 @@ namespace Hutopy.Infrastructure.Data.Migrations
|
||||
|
||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("FuturCreator", b =>
|
||||
modelBuilder.Entity("FuturCreators", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
@@ -71,7 +71,7 @@ namespace Hutopy.Infrastructure.Data.Migrations
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("FuturCreator");
|
||||
b.ToTable("FuturCreators");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Hutopy.Domain.Entities.TodoItem", b =>
|
||||
|
||||
@@ -6,7 +6,7 @@ using Microsoft.EntityFrameworkCore.Migrations;
|
||||
namespace Hutopy.Infrastructure.Data.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class AddFuturCreator : Migration
|
||||
public partial class AddFuturCreators : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
@@ -48,7 +48,7 @@ namespace Hutopy.Infrastructure.Data.Migrations
|
||||
oldMaxLength: 128);
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "FuturCreator",
|
||||
name: "FuturCreators",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
@@ -66,7 +66,7 @@ namespace Hutopy.Infrastructure.Data.Migrations
|
||||
},
|
||||
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)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "FuturCreator");
|
||||
name: "FuturCreators");
|
||||
|
||||
migrationBuilder.AlterColumn<string>(
|
||||
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"
|
||||
},
|
||||
"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": {
|
||||
"get": {
|
||||
"tags": [
|
||||
@@ -757,6 +795,30 @@
|
||||
},
|
||||
"components": {
|
||||
"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": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
|
||||
Reference in New Issue
Block a user