Started FuturCreator
This commit is contained in:
@@ -8,5 +8,7 @@ public interface IApplicationDbContext
|
|||||||
|
|
||||||
DbSet<TodoItem> TodoItems { get; }
|
DbSet<TodoItem> TodoItems { get; }
|
||||||
|
|
||||||
|
DbSet<FuturCreator> FuturCreator { get; }
|
||||||
|
|
||||||
Task<int> SaveChangesAsync(CancellationToken cancellationToken);
|
Task<int> SaveChangesAsync(CancellationToken cancellationToken);
|
||||||
}
|
}
|
||||||
|
|||||||
43
src/Application/FuturCreator/Commands/CreateFuturCreator.cs
Normal file
43
src/Application/FuturCreator/Commands/CreateFuturCreator.cs
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
using Hutopy.Application.Common.Interfaces;
|
||||||
|
|
||||||
|
namespace Hutopy.Application.TodoItems.Commands.CreateFuturCreator;
|
||||||
|
|
||||||
|
public record CreateFuturCreatorCommand : IRequest<int>
|
||||||
|
{
|
||||||
|
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; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class CreateFuturCreatorCommandHandler : IRequestHandler<CreateFuturCreatorCommand, int>
|
||||||
|
{
|
||||||
|
private readonly IApplicationDbContext _context;
|
||||||
|
|
||||||
|
|
||||||
|
public CreateFuturCreatorCommandHandler(IApplicationDbContext context)
|
||||||
|
{
|
||||||
|
_context = context;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<int> Handle(CreateFuturCreatorCommand request, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
var entity = new FuturCreator()
|
||||||
|
{
|
||||||
|
FirstName = request.FirstName,
|
||||||
|
LastName = request.LastName,
|
||||||
|
EmailAddress = request.EmailAddress,
|
||||||
|
PhoneNumber = request.PhoneNumber,
|
||||||
|
SocialNetworkAccount = request.SocialNetworkAccount,
|
||||||
|
ReasonToJoin = request.ReasonToJoin,
|
||||||
|
};
|
||||||
|
|
||||||
|
_context.FuturCreator.Add(entity);
|
||||||
|
|
||||||
|
await _context.SaveChangesAsync(cancellationToken);
|
||||||
|
|
||||||
|
return entity.Id;
|
||||||
|
}
|
||||||
|
}
|
||||||
9
src/Domain/Entities/FuturCreator.cs
Normal file
9
src/Domain/Entities/FuturCreator.cs
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
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; }
|
||||||
|
}
|
||||||
@@ -2,6 +2,7 @@
|
|||||||
using Hutopy.Application.Common.Interfaces;
|
using Hutopy.Application.Common.Interfaces;
|
||||||
using Hutopy.Domain.Entities;
|
using Hutopy.Domain.Entities;
|
||||||
using Hutopy.Infrastructure.Identity;
|
using Hutopy.Infrastructure.Identity;
|
||||||
|
using Microsoft.AspNetCore.Identity;
|
||||||
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
|
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
@@ -15,6 +16,8 @@ public class ApplicationDbContext : IdentityDbContext<ApplicationUser>, IApplica
|
|||||||
|
|
||||||
public DbSet<TodoItem> TodoItems => Set<TodoItem>();
|
public DbSet<TodoItem> TodoItems => Set<TodoItem>();
|
||||||
|
|
||||||
|
public DbSet<FuturCreator> FuturCreator => Set<FuturCreator>();
|
||||||
|
|
||||||
protected override void OnModelCreating(ModelBuilder builder)
|
protected override void OnModelCreating(ModelBuilder builder)
|
||||||
{
|
{
|
||||||
base.OnModelCreating(builder);
|
base.OnModelCreating(builder);
|
||||||
|
|||||||
Reference in New Issue
Block a user