Feature: Join us api call
This commit is contained in:
@@ -8,7 +8,7 @@ public interface IApplicationDbContext
|
||||
|
||||
DbSet<TodoItem> TodoItems { get; }
|
||||
|
||||
DbSet<FuturCreator> FuturCreators { get; }
|
||||
DbSet<FutureCreator> FutureCreators { get; }
|
||||
|
||||
Task<int> SaveChangesAsync(CancellationToken cancellationToken);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System.Reflection;
|
||||
using Hutopy.Application.Common.Behaviours;
|
||||
|
||||
namespace Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
using Hutopy.Application.Common.Interfaces;
|
||||
using Hutopy.Domain.Entities;
|
||||
|
||||
namespace Hutopy.Application.FuturCreators.Commands.CreateFuturCreator;
|
||||
namespace Hutopy.Application.FutureCreators.Commands;
|
||||
|
||||
public record CreateFuturCreatorCommand : IRequest<int>
|
||||
public record CreateFutureCreatorCommand : IRequest<int>
|
||||
{
|
||||
public required string FirstName { get; init; }
|
||||
public required string LastName { get; init; }
|
||||
@@ -13,7 +13,7 @@ public record CreateFuturCreatorCommand : IRequest<int>
|
||||
public required string ReasonToJoin { get; init; }
|
||||
}
|
||||
|
||||
public class CreateFuturCreatorCommandHandler : IRequestHandler<CreateFuturCreatorCommand, int>
|
||||
public class CreateFuturCreatorCommandHandler : IRequestHandler<CreateFutureCreatorCommand, int>
|
||||
{
|
||||
private readonly IApplicationDbContext _context;
|
||||
|
||||
@@ -23,9 +23,9 @@ public class CreateFuturCreatorCommandHandler : IRequestHandler<CreateFuturCreat
|
||||
_context = context;
|
||||
}
|
||||
|
||||
public async Task<int> Handle(CreateFuturCreatorCommand request, CancellationToken cancellationToken)
|
||||
public async Task<int> Handle(CreateFutureCreatorCommand request, CancellationToken cancellationToken)
|
||||
{
|
||||
var entity = new FuturCreator()
|
||||
var entity = new FutureCreator
|
||||
{
|
||||
FirstName = request.FirstName,
|
||||
LastName = request.LastName,
|
||||
@@ -35,7 +35,7 @@ public class CreateFuturCreatorCommandHandler : IRequestHandler<CreateFuturCreat
|
||||
ReasonToJoin = request.ReasonToJoin,
|
||||
};
|
||||
|
||||
_context.FuturCreators.Add(entity);
|
||||
_context.FutureCreators.Add(entity);
|
||||
|
||||
await _context.SaveChangesAsync(cancellationToken);
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
namespace Hutopy.Domain.Entities;
|
||||
|
||||
public class FuturCreator : BaseAuditableEntity
|
||||
{
|
||||
public required string FirstName { get; set; }
|
||||
public required string LastName { get; set; }
|
||||
public required string EmailAddress { get; set; }
|
||||
public required string PhoneNumber { get; set; }
|
||||
public required string SocialNetworkAccount { get; set; }
|
||||
public required string ReasonToJoin { get; set; }
|
||||
}
|
||||
11
src/Domain/Entities/FutureCreator.cs
Normal file
11
src/Domain/Entities/FutureCreator.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
namespace Hutopy.Domain.Entities;
|
||||
|
||||
public class FutureCreator : BaseAuditableEntity
|
||||
{
|
||||
public required string FirstName { get; init; }
|
||||
public required string LastName { get; init; }
|
||||
public required string EmailAddress { get; init; }
|
||||
public required string PhoneNumber { get; init; }
|
||||
public required string SocialNetworkAccount { get; init; }
|
||||
public required string ReasonToJoin { get; init; }
|
||||
}
|
||||
@@ -16,7 +16,7 @@ public class ApplicationDbContext : IdentityDbContext<ApplicationUser>, IApplica
|
||||
|
||||
public DbSet<TodoItem> TodoItems => Set<TodoItem>();
|
||||
|
||||
public DbSet<FuturCreator> FuturCreators => Set<FuturCreator>();
|
||||
public DbSet<FutureCreator> FutureCreators => Set<FutureCreator>();
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder builder)
|
||||
{
|
||||
|
||||
@@ -48,7 +48,7 @@ namespace Hutopy.Infrastructure.Data.Migrations
|
||||
oldMaxLength: 128);
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "FuturCreators",
|
||||
name: "FutureCreators",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
@@ -74,7 +74,7 @@ namespace Hutopy.Infrastructure.Data.Migrations
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "FuturCreators");
|
||||
name: "FutureCreators");
|
||||
|
||||
migrationBuilder.AlterColumn<string>(
|
||||
name: "Name",
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace Hutopy.Infrastructure.Data.Migrations
|
||||
|
||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("Hutopy.Domain.Entities.FuturCreator", b =>
|
||||
modelBuilder.Entity("Hutopy.Domain.Entities.FutureCreator", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
@@ -68,7 +68,7 @@ namespace Hutopy.Infrastructure.Data.Migrations
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("FuturCreator");
|
||||
b.ToTable("FutureCreator");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Hutopy.Domain.Entities.TodoItem", b =>
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
17
src/Web/Endpoints/JoinUs.cs
Normal file
17
src/Web/Endpoints/JoinUs.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using Hutopy.Application.FutureCreators.Commands;
|
||||
|
||||
namespace Hutopy.Web.Endpoints;
|
||||
|
||||
public class JoinUs : EndpointGroupBase
|
||||
{
|
||||
public override void Map(WebApplication app)
|
||||
{
|
||||
app.MapGroup(this)
|
||||
.MapPost(CreateFutureCreator);
|
||||
}
|
||||
|
||||
public Task<int> CreateFutureCreator(ISender sender, CreateFutureCreatorCommand command)
|
||||
{
|
||||
return sender.Send(command);
|
||||
}
|
||||
}
|
||||
@@ -6,18 +6,18 @@
|
||||
"version": "1.0.0"
|
||||
},
|
||||
"paths": {
|
||||
"/api/FuturCreators": {
|
||||
"/api/JoinUs": {
|
||||
"post": {
|
||||
"tags": [
|
||||
"FuturCreators"
|
||||
"JoinUs"
|
||||
],
|
||||
"operationId": "CreateFuturCreator",
|
||||
"operationId": "CreateFutureCreator",
|
||||
"requestBody": {
|
||||
"x-name": "command",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/CreateFuturCreatorCommand"
|
||||
"$ref": "#/components/schemas/CreateFutureCreatorCommand"
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -36,12 +36,7 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"security": [
|
||||
{
|
||||
"JWT": []
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"/api/TodoItems": {
|
||||
@@ -795,7 +790,7 @@
|
||||
},
|
||||
"components": {
|
||||
"schemas": {
|
||||
"CreateFuturCreatorCommand": {
|
||||
"CreateFutureCreatorCommand": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
|
||||
Reference in New Issue
Block a user