From c20f6c543ea72fc944cca06f06a616bd2f3cc35b Mon Sep 17 00:00:00 2001 From: Xavier Date: Fri, 3 Nov 2023 09:46:45 -0700 Subject: [PATCH] Update to FunctionalDdd 1.1.0-alpha.32 Update to FunctionalDdd 1.1.0-alpha.32 --- .../2022-12-21/Controllers/MenusController.cs | 1 - .../Models/Menus/CreateMenuRequest.cs | 20 ++++----- .../Controllers/AuthenticationController.cs | 1 - .../Models/Authentication/LoginRequest.cs | 6 +-- .../Models/Authentication/RegisterRequest.cs | 13 +++--- .../2022-12-21/CreateMenuRequestTests.cs | 35 +++++++-------- Api/tests/Neutral/LoginRequestTests.cs | 5 +-- Api/tests/Neutral/RegisterRequestTests.cs | 12 +++-- .../Persistence/IRepository{T}.cs | 2 - .../Commands/RegisterCommand.cs | 3 +- .../Commands/RegisterCommandHandler.cs | 2 +- .../src/Authentication/Queries/LoginQuery.cs | 2 +- .../src/Menus/Commands/CreateMenuCommand.cs | 6 +-- .../Commands/CreateMenuCommandHandler.cs | 6 +-- .../Authentication/AuthenticationTests.cs | 13 +++--- Directory.Build.props | 2 +- Directory.Packages.props | 14 +++--- .../Common/Errors/Errors.Authentication.cs | 2 - Domain/src/Common/Errors/Errors.User.cs | 2 - Domain/src/Common/ValueObjects/Description.cs | 2 - Domain/src/Common/ValueObjects/Name.cs | 2 - Domain/src/Dinner/ValueObjects/DinnerId.cs | 2 - Domain/src/Host/ValueObjects/HostId.cs | 2 - Domain/src/Menu/Entities/MenuItem.cs | 7 ++- Domain/src/Menu/Entities/MenuSection.cs | 7 ++- Domain/src/Menu/Menu.cs | 7 ++- Domain/src/Menu/ValueObjects/MenuId.cs | 2 - Domain/src/Menu/ValueObjects/MenuItemId.cs | 2 - Domain/src/Menu/ValueObjects/MenuSectionId.cs | 2 - Domain/src/MenuReview/ValueObjects/MenuId.cs | 2 - Domain/src/User/Entities/User.cs | 3 +- Domain/src/User/ValueObjects/FirstName.cs | 2 - Domain/src/User/ValueObjects/LastName.cs | 2 - Domain/src/User/ValueObjects/Password.cs | 2 - Domain/src/User/ValueObjects/UserId.cs | 2 - Domain/tests/MenuTests.cs | 45 +++++++++---------- Domain/tests/UserTests.cs | 26 +++++------ Infrastructure/src/Persistence/Dto/MenuDto.cs | 14 +++--- .../src/Persistence/Dto/MenuISectionDto.cs | 8 ++-- .../src/Persistence/Dto/MenuItemDto.cs | 8 ++-- Infrastructure/src/Persistence/Dto/UserDto.cs | 13 +++--- Infrastructure/tests/MenuRepositoryTests.cs | 30 ++++++------- Infrastructure/tests/UserRespositoryTests.cs | 13 +++--- 43 files changed, 151 insertions(+), 201 deletions(-) diff --git a/Api/src/2022-12-21/Controllers/MenusController.cs b/Api/src/2022-12-21/Controllers/MenusController.cs index 40fb144..17283da 100644 --- a/Api/src/2022-12-21/Controllers/MenusController.cs +++ b/Api/src/2022-12-21/Controllers/MenusController.cs @@ -2,7 +2,6 @@ using Asp.Versioning; using BuberDinner.Api._2022_12_21.Models.Menus; -using FunctionalDDD.Asp; using Mapster; using Mediator; using Microsoft.AspNetCore.Mvc; diff --git a/Api/src/2022-12-21/Models/Menus/CreateMenuRequest.cs b/Api/src/2022-12-21/Models/Menus/CreateMenuRequest.cs index d55c4ce..1dea0b6 100644 --- a/Api/src/2022-12-21/Models/Menus/CreateMenuRequest.cs +++ b/Api/src/2022-12-21/Models/Menus/CreateMenuRequest.cs @@ -17,11 +17,11 @@ public record CreateMenuRequest( List Sections) { internal Result ToCreateMenuCommand(string hostId) => - NameClass.New(this.Name) - .Combine(DescriptionClass.New(this.Description)) + NameClass.TryCreate(this.Name) + .Combine(DescriptionClass.TryCreate(this.Description)) .Combine(this.GetMenuSectionCommands()) - .Combine(HostId.New(hostId)) - .Bind(CreateMenuCommand.New); + .Combine(HostId.TryCreate(hostId)) + .Bind(CreateMenuCommand.TryCreate); private Result> GetMenuSectionCommands() => this.Sections @@ -41,10 +41,10 @@ public record MenuSectionRequest( List Items) { internal Result ToMenuSectionCommand() => - NameClass.New(this.Name) - .Combine(DescriptionClass.New(this.Description)) + NameClass.TryCreate(this.Name) + .Combine(DescriptionClass.TryCreate(this.Description)) .Combine(this.GetMenuItemCommands()) - .Bind(MenuSectionCommand.New); + .Bind(MenuSectionCommand.TryCreate); private Result> GetMenuItemCommands() => this.Items @@ -62,7 +62,7 @@ public record MenuItemRequest( string Description) { internal Result ToMenuItemCommand() => - NameClass.New(this.Name) - .Combine(DescriptionClass.New(this.Description)) - .Bind(MenuItemCommand.New); + NameClass.TryCreate(this.Name) + .Combine(DescriptionClass.TryCreate(this.Description)) + .Bind(MenuItemCommand.TryCreate); } diff --git a/Api/src/Neutral/Controllers/AuthenticationController.cs b/Api/src/Neutral/Controllers/AuthenticationController.cs index 57b70b7..36c2dab 100644 --- a/Api/src/Neutral/Controllers/AuthenticationController.cs +++ b/Api/src/Neutral/Controllers/AuthenticationController.cs @@ -2,7 +2,6 @@ using Asp.Versioning; using BuberDinner.Api.Neutral.Models.Authentication; -using FunctionalDDD.Asp; using Mapster; using Mediator; using Microsoft.AspNetCore.Authorization; diff --git a/Api/src/Neutral/Models/Authentication/LoginRequest.cs b/Api/src/Neutral/Models/Authentication/LoginRequest.cs index 961ec9d..7a38d3a 100644 --- a/Api/src/Neutral/Models/Authentication/LoginRequest.cs +++ b/Api/src/Neutral/Models/Authentication/LoginRequest.cs @@ -14,7 +14,7 @@ public record LoginRequest( string Password) { internal Result ToLoginQuery() => - UserIdClass.New(UserId) - .Combine(PasswordClass.New(Password)) - .Bind((userId, pwd) => LoginQuery.New(userId, pwd)); + UserIdClass.TryCreate(UserId) + .Combine(PasswordClass.TryCreate(Password)) + .Bind((userId, pwd) => LoginQuery.TryCreate(userId, pwd)); } diff --git a/Api/src/Neutral/Models/Authentication/RegisterRequest.cs b/Api/src/Neutral/Models/Authentication/RegisterRequest.cs index c344b74..7d102e2 100644 --- a/Api/src/Neutral/Models/Authentication/RegisterRequest.cs +++ b/Api/src/Neutral/Models/Authentication/RegisterRequest.cs @@ -1,7 +1,6 @@ namespace BuberDinner.Api.Neutral.Models.Authentication; using BuberDinner.Application.Services.Authentication.Commands; -using FunctionalDDD.Domain; using FirstNameClass = Domain.User.ValueObjects.FirstName; using LastNameClass = Domain.User.ValueObjects.LastName; using PasswordClass = Domain.User.ValueObjects.Password; @@ -25,11 +24,11 @@ string Password { internal Result ToRegisterCommand() => - UserIdClass.New(UserId) - .Combine(FirstNameClass.New(FirstName)) - .Combine(LastNameClass.New(LastName)) - .Combine(EmailAddress.New(Email)) - .Combine(PasswordClass.New(Password)) - .Bind(RegisterCommand.New); + UserIdClass.TryCreate(UserId) + .Combine(FirstNameClass.TryCreate(FirstName)) + .Combine(LastNameClass.TryCreate(LastName)) + .Combine(EmailAddress.TryCreate(Email)) + .Combine(PasswordClass.TryCreate(Password)) + .Bind(RegisterCommand.TryCreate); }; diff --git a/Api/tests/2022-12-21/CreateMenuRequestTests.cs b/Api/tests/2022-12-21/CreateMenuRequestTests.cs index d2a25d9..9130624 100644 --- a/Api/tests/2022-12-21/CreateMenuRequestTests.cs +++ b/Api/tests/2022-12-21/CreateMenuRequestTests.cs @@ -4,7 +4,6 @@ using BuberDinner.Application.Menus.Commands; using BuberDinner.Domain.Common.ValueObjects; using BuberDinner.Domain.Host.ValueObject; -using FunctionalDDD.Results.Errors; public class CreateMenuRequestTests { @@ -161,46 +160,46 @@ public void Can_create_CreateMenuCommand() // Assert result.IsSuccess.Should().BeTrue(); CreateMenuCommand createMenuCommand = result.Value; - createMenuCommand.Name.Should().Be(Name.New(request.Name).Value); - createMenuCommand.Description.Should().Be(Description.New(request.Description).Value); - createMenuCommand.HostId.Should().Be(HostId.New(Guid.Parse(hostId)).Value); + createMenuCommand.Name.Should().Be(Name.TryCreate(request.Name).Value); + createMenuCommand.Description.Should().Be(Description.TryCreate(request.Description).Value); + createMenuCommand.HostId.Should().Be(HostId.TryCreate(Guid.Parse(hostId)).Value); createMenuCommand.Sections.Count.Should().Be(2); MenuSectionRequest section0Request = request.Sections[0]; MenuSectionCommand section0Command = createMenuCommand.Sections[0]; - section0Command.Name.Should().Be(Name.New(section0Request.Name).Value); - section0Command.Description.Should().Be(Description.New(section0Request.Description).Value); + section0Command.Name.Should().Be(Name.TryCreate(section0Request.Name).Value); + section0Command.Description.Should().Be(Description.TryCreate(section0Request.Description).Value); section0Command.Items.Count.Should().Be(3); MenuSectionRequest section1Request = request.Sections[1]; MenuSectionCommand section1Command = createMenuCommand.Sections[1]; - section1Command.Name.Should().Be(Name.New(section1Request.Name).Value); - section1Command.Description.Should().Be(Description.New(section1Request.Description).Value); + section1Command.Name.Should().Be(Name.TryCreate(section1Request.Name).Value); + section1Command.Description.Should().Be(Description.TryCreate(section1Request.Description).Value); section1Command.Items.Count.Should().Be(2); MenuItemRequest item0_0Request = section0Request.Items[0]; MenuItemCommand item0_0Command = section0Command.Items[0]; - item0_0Command.Name.Should().Be(Name.New(item0_0Request.Name).Value); - item0_0Command.Description.Should().Be(Description.New(item0_0Request.Description).Value); + item0_0Command.Name.Should().Be(Name.TryCreate(item0_0Request.Name).Value); + item0_0Command.Description.Should().Be(Description.TryCreate(item0_0Request.Description).Value); MenuItemRequest item0_1Request = section0Request.Items[1]; MenuItemCommand item0_1Command = section0Command.Items[1]; - item0_1Command.Name.Should().Be(Name.New(item0_1Request.Name).Value); - item0_1Command.Description.Should().Be(Description.New(item0_1Request.Description).Value); + item0_1Command.Name.Should().Be(Name.TryCreate(item0_1Request.Name).Value); + item0_1Command.Description.Should().Be(Description.TryCreate(item0_1Request.Description).Value); MenuItemRequest item0_2Request = section0Request.Items[2]; MenuItemCommand item0_2Command = section0Command.Items[2]; - item0_2Command.Name.Should().Be(Name.New(item0_2Request.Name).Value); - item0_2Command.Description.Should().Be(Description.New(item0_2Request.Description).Value); + item0_2Command.Name.Should().Be(Name.TryCreate(item0_2Request.Name).Value); + item0_2Command.Description.Should().Be(Description.TryCreate(item0_2Request.Description).Value); MenuItemRequest item1_0Request = section1Request.Items[0]; MenuItemCommand item1_0Command = section1Command.Items[0]; - item1_0Command.Name.Should().Be(Name.New(item1_0Request.Name).Value); - item1_0Command.Description.Should().Be(Description.New(item1_0Request.Description).Value); + item1_0Command.Name.Should().Be(Name.TryCreate(item1_0Request.Name).Value); + item1_0Command.Description.Should().Be(Description.TryCreate(item1_0Request.Description).Value); MenuItemRequest item1_1Request = section1Request.Items[1]; MenuItemCommand item1_1Command = section1Command.Items[1]; - item1_1Command.Name.Should().Be(Name.New(item1_1Request.Name).Value); - item1_1Command.Description.Should().Be(Description.New(item1_1Request.Description).Value); + item1_1Command.Name.Should().Be(Name.TryCreate(item1_1Request.Name).Value); + item1_1Command.Description.Should().Be(Description.TryCreate(item1_1Request.Description).Value); } } diff --git a/Api/tests/Neutral/LoginRequestTests.cs b/Api/tests/Neutral/LoginRequestTests.cs index 5f6e4d3..6ce944e 100644 --- a/Api/tests/Neutral/LoginRequestTests.cs +++ b/Api/tests/Neutral/LoginRequestTests.cs @@ -2,7 +2,6 @@ using BuberDinner.Api.Neutral.Models.Authentication; using BuberDinner.Domain.User.ValueObjects; -using FunctionalDDD.Results.Errors; public class LoginRequestTests { @@ -37,7 +36,7 @@ public void Can_create_LoginQuery() // Assert result.IsSuccess.Should().BeTrue(); var registerCommand = result.Value; - registerCommand.UserId.Should().Be(UserId.New("xavierjohn2023").Value); - registerCommand.Password.Should().Be(Password.New("password").Value); + registerCommand.UserId.Should().Be(UserId.TryCreate("xavierjohn2023").Value); + registerCommand.Password.Should().Be(Password.TryCreate("password").Value); } } diff --git a/Api/tests/Neutral/RegisterRequestTests.cs b/Api/tests/Neutral/RegisterRequestTests.cs index 56d6791..9408855 100644 --- a/Api/tests/Neutral/RegisterRequestTests.cs +++ b/Api/tests/Neutral/RegisterRequestTests.cs @@ -2,8 +2,6 @@ using BuberDinner.Api.Neutral.Models.Authentication; using BuberDinner.Domain.User.ValueObjects; -using FunctionalDDD.Domain; -using FunctionalDDD.Results.Errors; public class RegisterRequestTests { @@ -64,10 +62,10 @@ public void Can_create_RegisterCommand() // Assert result.IsSuccess.Should().BeTrue(); var registerCommand = result.Value; - registerCommand.UserId.Should().Be(UserId.New("id").Value); - registerCommand.FirstName.Should().Be(FirstName.New("Xavier").Value); - registerCommand.LastName.Should().Be(LastName.New("John").Value); - registerCommand.Email.Should().Be(EmailAddress.New("xavier@somewhere.com").Value); - registerCommand.Password.Should().Be(Password.New("password").Value); + registerCommand.UserId.Should().Be(UserId.TryCreate("id").Value); + registerCommand.FirstName.Should().Be(FirstName.TryCreate("Xavier").Value); + registerCommand.LastName.Should().Be(LastName.TryCreate("John").Value); + registerCommand.Email.Should().Be(EmailAddress.TryCreate("xavier@somewhere.com").Value); + registerCommand.Password.Should().Be(Password.TryCreate("password").Value); } } diff --git a/Application/src/Abstractions/Persistence/IRepository{T}.cs b/Application/src/Abstractions/Persistence/IRepository{T}.cs index 95fe6f1..50d95ce 100644 --- a/Application/src/Abstractions/Persistence/IRepository{T}.cs +++ b/Application/src/Abstractions/Persistence/IRepository{T}.cs @@ -1,7 +1,5 @@ namespace BuberDinner.Application.Abstractions.Persistence; -using FunctionalDDD; - public interface IRepository where T : class { IEnumerable GetAll(CancellationToken cancellationToken); diff --git a/Application/src/Authentication/Commands/RegisterCommand.cs b/Application/src/Authentication/Commands/RegisterCommand.cs index dbe77bd..1a6a5a4 100644 --- a/Application/src/Authentication/Commands/RegisterCommand.cs +++ b/Application/src/Authentication/Commands/RegisterCommand.cs @@ -2,13 +2,12 @@ using BuberDinner.Application.Services.Authentication.Common; using BuberDinner.Domain.User.ValueObjects; -using FunctionalDDD.Domain; using Mediator; public class RegisterCommand : IRequest> { - public static Result New(UserId id, FirstName firstName, LastName lastName, EmailAddress email, Password password) => + public static Result TryCreate(UserId id, FirstName firstName, LastName lastName, EmailAddress email, Password password) => new RegisterCommand(id, firstName, lastName, email, password); public UserId UserId { get; } diff --git a/Application/src/Authentication/Commands/RegisterCommandHandler.cs b/Application/src/Authentication/Commands/RegisterCommandHandler.cs index 0c41c17..eff3bd2 100644 --- a/Application/src/Authentication/Commands/RegisterCommandHandler.cs +++ b/Application/src/Authentication/Commands/RegisterCommandHandler.cs @@ -32,7 +32,7 @@ public ValueTask> Handle(RegisterCommand request, C }); private async ValueTask> CreateUser(RegisterCommand command, CancellationToken cancellationToken) => - await User.New(command.UserId, command.FirstName, command.LastName, command.Email, command.Password) + await User.TryCreate(command.UserId, command.FirstName, command.LastName, command.Email, command.Password) .TapAsync(user => _userRepository.Add(user, cancellationToken)); private async ValueTask> ValidateUserDoesNotExist(UserId id, CancellationToken cancellationToken) diff --git a/Application/src/Authentication/Queries/LoginQuery.cs b/Application/src/Authentication/Queries/LoginQuery.cs index d3cf586..73d1a32 100644 --- a/Application/src/Authentication/Queries/LoginQuery.cs +++ b/Application/src/Authentication/Queries/LoginQuery.cs @@ -15,6 +15,6 @@ private LoginQuery(UserId userId, Password password) public UserId UserId { get; } public Password Password { get; } - public static Result New(UserId userId, Password password) => + public static Result TryCreate(UserId userId, Password password) => new LoginQuery(userId, password); } diff --git a/Application/src/Menus/Commands/CreateMenuCommand.cs b/Application/src/Menus/Commands/CreateMenuCommand.cs index 4e98756..9b26cdd 100644 --- a/Application/src/Menus/Commands/CreateMenuCommand.cs +++ b/Application/src/Menus/Commands/CreateMenuCommand.cs @@ -7,7 +7,7 @@ public class CreateMenuCommand : IRequest> { - public static Result New( + public static Result TryCreate( Name name, Description description, IReadOnlyList sections, @@ -34,7 +34,7 @@ private CreateMenuCommand( public class MenuSectionCommand { - public static Result New( + public static Result TryCreate( Name name, Description description, IReadOnlyList items) => @@ -54,7 +54,7 @@ private MenuSectionCommand(Name name, Description description, IReadOnlyList New( + public static Result TryCreate( Name name, Description description) => new MenuItemCommand(name, description); diff --git a/Application/src/Menus/Commands/CreateMenuCommandHandler.cs b/Application/src/Menus/Commands/CreateMenuCommandHandler.cs index 55f28fc..a059f1f 100644 --- a/Application/src/Menus/Commands/CreateMenuCommandHandler.cs +++ b/Application/src/Menus/Commands/CreateMenuCommandHandler.cs @@ -20,16 +20,16 @@ public ValueTask> Handle(CreateMenuCommand request, CancellationTok CreateMenu(request, cancellationToken); private async ValueTask> CreateMenu(CreateMenuCommand request, CancellationToken cancellationToken) => - await Menu.New(request.Name, request.Description, CreateMenuSections(request.Sections), request.HostId) + await Menu.TryCreate(request.Name, request.Description, CreateMenuSections(request.Sections), request.HostId) .TapAsync(menu => _menuRepository.Add(menu, cancellationToken)); private static IReadOnlyList CreateMenuSections(IReadOnlyList commands) => commands - .Select(msc => MenuSection.New(msc.Name, msc.Description, CreateMenuItems(msc.Items)).Value) + .Select(msc => MenuSection.TryCreate(msc.Name, msc.Description, CreateMenuItems(msc.Items)).Value) .ToList(); private static IReadOnlyList CreateMenuItems(IReadOnlyList commands) => commands - .Select(mic => MenuItem.New(mic.Name, mic.Description).Value) + .Select(mic => MenuItem.TryCreate(mic.Name, mic.Description).Value) .ToList(); } diff --git a/Application/tests/Authentication/AuthenticationTests.cs b/Application/tests/Authentication/AuthenticationTests.cs index f994f33..6648f05 100644 --- a/Application/tests/Authentication/AuthenticationTests.cs +++ b/Application/tests/Authentication/AuthenticationTests.cs @@ -3,7 +3,6 @@ using System.Threading.Tasks; using BuberDinner.Application.Services.Authentication.Commands; using BuberDinner.Domain.User.ValueObjects; - using FunctionalDDD.Domain; using Mediator; public class AuthenticationTests @@ -20,12 +19,12 @@ public AuthenticationTests(ISender sender) public async Task Can_Register_new_User() { // Arrange - var userId = UserId.New("xavierjohn2023").Value; - var firstName = FirstName.New("Xavier").Value; - var lastName = LastName.New("John").Value; - var email = EmailAddress.New("xavier@somewhere.com").Value; - var password = Password.New("SuperStrongPassword").Value; - var command = RegisterCommand.New(userId, firstName, lastName, email, password).Value; + var userId = UserId.TryCreate("xavierjohn2023").Value; + var firstName = FirstName.TryCreate("Xavier").Value; + var lastName = LastName.TryCreate("John").Value; + var email = EmailAddress.TryCreate("xavier@somewhere.com").Value; + var password = Password.TryCreate("SuperStrongPassword").Value; + var command = RegisterCommand.TryCreate(userId, firstName, lastName, email, password).Value; // Act Result result = await _sender.Send(command); diff --git a/Directory.Build.props b/Directory.Build.props index b343077..50e84fe 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -23,7 +23,7 @@ - + diff --git a/Directory.Packages.props b/Directory.Packages.props index 043c73d..2be06f4 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -1,18 +1,18 @@ - 1.1.0-alpha.28 + 1.1.0-alpha.32 - - - - - - + + + + + + diff --git a/Domain/src/Common/Errors/Errors.Authentication.cs b/Domain/src/Common/Errors/Errors.Authentication.cs index cc18acc..d51466e 100644 --- a/Domain/src/Common/Errors/Errors.Authentication.cs +++ b/Domain/src/Common/Errors/Errors.Authentication.cs @@ -1,7 +1,5 @@ namespace BuberDinner.Domain.Errors; -using FunctionalDDD.Results.Errors; - public partial class Errors { public static class Authentication diff --git a/Domain/src/Common/Errors/Errors.User.cs b/Domain/src/Common/Errors/Errors.User.cs index e06ca17..1e30412 100644 --- a/Domain/src/Common/Errors/Errors.User.cs +++ b/Domain/src/Common/Errors/Errors.User.cs @@ -1,7 +1,5 @@ namespace BuberDinner.Domain.Errors; -using FunctionalDDD.Results.Errors; - public partial class Errors { public static class User diff --git a/Domain/src/Common/ValueObjects/Description.cs b/Domain/src/Common/ValueObjects/Description.cs index c944060..ca33e75 100644 --- a/Domain/src/Common/ValueObjects/Description.cs +++ b/Domain/src/Common/ValueObjects/Description.cs @@ -1,7 +1,5 @@ namespace BuberDinner.Domain.Common.ValueObjects; -using FunctionalDDD.Domain; - public partial class Description : RequiredString { } diff --git a/Domain/src/Common/ValueObjects/Name.cs b/Domain/src/Common/ValueObjects/Name.cs index 44eb766..74f0916 100644 --- a/Domain/src/Common/ValueObjects/Name.cs +++ b/Domain/src/Common/ValueObjects/Name.cs @@ -1,7 +1,5 @@ namespace BuberDinner.Domain.Common.ValueObjects; -using FunctionalDDD.Domain; - public partial class Name : RequiredString { } diff --git a/Domain/src/Dinner/ValueObjects/DinnerId.cs b/Domain/src/Dinner/ValueObjects/DinnerId.cs index 6bb8583..0e86bc2 100644 --- a/Domain/src/Dinner/ValueObjects/DinnerId.cs +++ b/Domain/src/Dinner/ValueObjects/DinnerId.cs @@ -1,7 +1,5 @@ namespace BuberDinner.Domain.Dinner.ValueObject; -using FunctionalDDD.Domain; - public partial class DinnerId : RequiredGuid { } diff --git a/Domain/src/Host/ValueObjects/HostId.cs b/Domain/src/Host/ValueObjects/HostId.cs index ef12211..02afd7c 100644 --- a/Domain/src/Host/ValueObjects/HostId.cs +++ b/Domain/src/Host/ValueObjects/HostId.cs @@ -1,7 +1,5 @@ namespace BuberDinner.Domain.Host.ValueObject; -using FunctionalDDD.Domain; - public partial class HostId : RequiredGuid { } diff --git a/Domain/src/Menu/Entities/MenuItem.cs b/Domain/src/Menu/Entities/MenuItem.cs index d4521fe..fc93bf4 100644 --- a/Domain/src/Menu/Entities/MenuItem.cs +++ b/Domain/src/Menu/Entities/MenuItem.cs @@ -3,19 +3,18 @@ using BuberDinner.Domain.Common.ValueObjects; using BuberDinner.Domain.Menu.ValueObject; using FluentValidation; -using FunctionalDDD.Domain; public class MenuItem : Entity { public Name Name { get; } public Description Description { get; } - public static Result New(Name name, Description description) + public static Result TryCreate(Name name, Description description) { - return New(MenuItemId.NewUnique(), name, description); + return TryCreate(MenuItemId.NewUnique(), name, description); } - public static Result New(MenuItemId menuItemId, Name name, Description description) + public static Result TryCreate(MenuItemId menuItemId, Name name, Description description) { MenuItem menuItem = new(menuItemId, name, description); return s_validator.ValidateToResult(menuItem); diff --git a/Domain/src/Menu/Entities/MenuSection.cs b/Domain/src/Menu/Entities/MenuSection.cs index d5ede74..ba933b6 100644 --- a/Domain/src/Menu/Entities/MenuSection.cs +++ b/Domain/src/Menu/Entities/MenuSection.cs @@ -3,7 +3,6 @@ using BuberDinner.Domain.Common.ValueObjects; using BuberDinner.Domain.Menu.ValueObject; using FluentValidation; -using FunctionalDDD.Domain; public class MenuSection : Entity { @@ -14,15 +13,15 @@ public class MenuSection : Entity private readonly List _menuItems = new(); - public static Result New( + public static Result TryCreate( Name name, Description description, IReadOnlyList items) { - return New(MenuSectionId.NewUnique(), name, description, items); + return TryCreate(MenuSectionId.NewUnique(), name, description, items); } - public static Result New( + public static Result TryCreate( MenuSectionId menuSectionId, Name name, Description description, diff --git a/Domain/src/Menu/Menu.cs b/Domain/src/Menu/Menu.cs index e131182..1fcafa6 100644 --- a/Domain/src/Menu/Menu.cs +++ b/Domain/src/Menu/Menu.cs @@ -7,7 +7,6 @@ using BuberDinner.Domain.Menu.Entities; using BuberDinner.Domain.Menu.ValueObject; using FluentValidation; -using FunctionalDDD.Domain; public class Menu : Aggregate { @@ -23,13 +22,13 @@ public class Menu : Aggregate private readonly List _dinnerIds = new(); private readonly List _menuReviewIds = new(); - public static Result New( + public static Result TryCreate( Name name, Description description, IReadOnlyList sections, HostId host) { - return New( + return TryCreate( MenuId.NewUnique(), name, description, @@ -40,7 +39,7 @@ public static Result New( null); } - public static Result New( + public static Result TryCreate( MenuId menuId, Name name, Description description, diff --git a/Domain/src/Menu/ValueObjects/MenuId.cs b/Domain/src/Menu/ValueObjects/MenuId.cs index 5325b78..3c413ca 100644 --- a/Domain/src/Menu/ValueObjects/MenuId.cs +++ b/Domain/src/Menu/ValueObjects/MenuId.cs @@ -1,7 +1,5 @@ namespace BuberDinner.Domain.Menu.ValueObject; -using FunctionalDDD.Domain; - public partial class MenuId : RequiredGuid { } diff --git a/Domain/src/Menu/ValueObjects/MenuItemId.cs b/Domain/src/Menu/ValueObjects/MenuItemId.cs index 86caa30..225bc03 100644 --- a/Domain/src/Menu/ValueObjects/MenuItemId.cs +++ b/Domain/src/Menu/ValueObjects/MenuItemId.cs @@ -1,7 +1,5 @@ namespace BuberDinner.Domain.Menu.ValueObject; -using FunctionalDDD.Domain; - public partial class MenuItemId : RequiredGuid { } diff --git a/Domain/src/Menu/ValueObjects/MenuSectionId.cs b/Domain/src/Menu/ValueObjects/MenuSectionId.cs index 9b7f3d3..2ef5970 100644 --- a/Domain/src/Menu/ValueObjects/MenuSectionId.cs +++ b/Domain/src/Menu/ValueObjects/MenuSectionId.cs @@ -1,7 +1,5 @@ namespace BuberDinner.Domain.Menu.ValueObject; -using FunctionalDDD.Domain; - public partial class MenuSectionId : RequiredGuid { } diff --git a/Domain/src/MenuReview/ValueObjects/MenuId.cs b/Domain/src/MenuReview/ValueObjects/MenuId.cs index 589dc66..92acf03 100644 --- a/Domain/src/MenuReview/ValueObjects/MenuId.cs +++ b/Domain/src/MenuReview/ValueObjects/MenuId.cs @@ -1,7 +1,5 @@ namespace BuberDinner.Domain.Menu.ValueObject; -using FunctionalDDD.Domain; - public partial class MenuReviewId : RequiredGuid { } diff --git a/Domain/src/User/Entities/User.cs b/Domain/src/User/Entities/User.cs index 2edb5ad..320d6d4 100644 --- a/Domain/src/User/Entities/User.cs +++ b/Domain/src/User/Entities/User.cs @@ -2,7 +2,6 @@ using BuberDinner.Domain.User.ValueObjects; using FluentValidation; -using FunctionalDDD.Domain; public class User : Entity { @@ -11,7 +10,7 @@ public class User : Entity public EmailAddress Email { get; } public Password Password { get; } - public static Result New(UserId id, FirstName firstName, LastName lastName, EmailAddress email, Password password) + public static Result TryCreate(UserId id, FirstName firstName, LastName lastName, EmailAddress email, Password password) { var user = new User(id, firstName, lastName, email, password); return s_validator.ValidateToResult(user); diff --git a/Domain/src/User/ValueObjects/FirstName.cs b/Domain/src/User/ValueObjects/FirstName.cs index eb42fad..d853db4 100644 --- a/Domain/src/User/ValueObjects/FirstName.cs +++ b/Domain/src/User/ValueObjects/FirstName.cs @@ -1,7 +1,5 @@ namespace BuberDinner.Domain.User.ValueObjects; -using FunctionalDDD.Domain; - public partial class FirstName : RequiredString { } diff --git a/Domain/src/User/ValueObjects/LastName.cs b/Domain/src/User/ValueObjects/LastName.cs index 35797cd..3532bcf 100644 --- a/Domain/src/User/ValueObjects/LastName.cs +++ b/Domain/src/User/ValueObjects/LastName.cs @@ -1,7 +1,5 @@ namespace BuberDinner.Domain.User.ValueObjects; -using FunctionalDDD.Domain; - public partial class LastName : RequiredString { } diff --git a/Domain/src/User/ValueObjects/Password.cs b/Domain/src/User/ValueObjects/Password.cs index 049d703..02f92c4 100644 --- a/Domain/src/User/ValueObjects/Password.cs +++ b/Domain/src/User/ValueObjects/Password.cs @@ -1,7 +1,5 @@ namespace BuberDinner.Domain.User.ValueObjects; -using FunctionalDDD.Domain; - public partial class Password : RequiredString { } diff --git a/Domain/src/User/ValueObjects/UserId.cs b/Domain/src/User/ValueObjects/UserId.cs index 5ccb51a..d923de4 100644 --- a/Domain/src/User/ValueObjects/UserId.cs +++ b/Domain/src/User/ValueObjects/UserId.cs @@ -1,7 +1,5 @@ namespace BuberDinner.Domain.User.ValueObjects; -using FunctionalDDD.Domain; - public partial class UserId : RequiredString { } diff --git a/Domain/tests/MenuTests.cs b/Domain/tests/MenuTests.cs index de28f4b..e32f4e7 100644 --- a/Domain/tests/MenuTests.cs +++ b/Domain/tests/MenuTests.cs @@ -5,7 +5,6 @@ using BuberDinner.Domain.Menu; using BuberDinner.Domain.Menu.Entities; using BuberDinner.Domain.Menu.ValueObject; -using FunctionalDDD.Results.Errors; public class MenuTests { @@ -18,16 +17,16 @@ public void MenuItem_Required_parameters_are_validated(string field) // Arrange MenuItemId? id = field == nameof(MenuItem.Id) ? default - : MenuItemId.New("2F45ACF9-6E51-4DC7-8732-DBE7F260E951").Value; + : MenuItemId.TryCreate("2F45ACF9-6E51-4DC7-8732-DBE7F260E951").Value; Name? name = field == nameof(Name) ? default - : Name.New("Item Name").Value; + : Name.TryCreate("Item Name").Value; Description? description = field == nameof(Description) ? default - : Description.New("Item Description").Value; + : Description.TryCreate("Item Description").Value; // Act - Result menuItemResult = MenuItem.New(id!, name!, description!); + Result menuItemResult = MenuItem.TryCreate(id!, name!, description!); // Assert menuItemResult.IsFailure.Should().BeTrue(); @@ -46,24 +45,24 @@ public void MenuSection_Required_parameters_are_validated(string field) // Arrange MenuSectionId? id = field == nameof(MenuSection.Id) ? default - : MenuSectionId.New("2F45ACF9-6E51-4DC7-8732-DBE7F260E952").Value; + : MenuSectionId.TryCreate("2F45ACF9-6E51-4DC7-8732-DBE7F260E952").Value; Name? name = field == nameof(Name) ? default - : Name.New("Section Name").Value; + : Name.TryCreate("Section Name").Value; Description? description = field == nameof(Description) ? default - : Description.New("Section Description").Value; + : Description.TryCreate("Section Description").Value; IReadOnlyList items = field == nameof(MenuSection.Items) ? new List() : new List() { - MenuItem.New( - Name.New("Item Name").Value, - Description.New("Item Description").Value).Value + MenuItem.TryCreate( + Name.TryCreate("Item Name").Value, + Description.TryCreate("Item Description").Value).Value }; // Act - Result menuSectionResult = MenuSection.New(id!, name!, description!, items); + Result menuSectionResult = MenuSection.TryCreate(id!, name!, description!, items); // Assert menuSectionResult.IsFailure.Should().BeTrue(); @@ -83,33 +82,33 @@ public void Menu_Required_parameters_are_validated(string field) // Arrange MenuId? id = field == nameof(Menu.Id) ? default - : MenuId.New("2F45ACF9-6E51-4DC7-8732-DBE7F260E953").Value; + : MenuId.TryCreate("2F45ACF9-6E51-4DC7-8732-DBE7F260E953").Value; Name? name = field == nameof(Name) ? default - : Name.New("Menu Name").Value; + : Name.TryCreate("Menu Name").Value; Description? description = field == nameof(Description) ? default - : Description.New("Menu Description").Value; + : Description.TryCreate("Menu Description").Value; IReadOnlyList sections = field == nameof(Menu.Sections) ? new List() : new List() { - MenuSection.New( - Name.New("Section Name").Value, - Description.New("Section Description").Value, + MenuSection.TryCreate( + Name.TryCreate("Section Name").Value, + Description.TryCreate("Section Description").Value, new List() { - MenuItem.New( - Name.New("Item Name").Value, - Description.New("Item Description").Value).Value + MenuItem.TryCreate( + Name.TryCreate("Item Name").Value, + Description.TryCreate("Item Description").Value).Value }).Value }; HostId? hostId = field == nameof(HostId) ? default - : HostId.New("2F45ACF9-6E51-4DC7-8732-DBE7F260E954").Value; + : HostId.TryCreate("2F45ACF9-6E51-4DC7-8732-DBE7F260E954").Value; // Act - Result menuResult = Menu.New( + Result menuResult = Menu.TryCreate( id!, name!, description!, diff --git a/Domain/tests/UserTests.cs b/Domain/tests/UserTests.cs index 5dccb30..bc6000c 100644 --- a/Domain/tests/UserTests.cs +++ b/Domain/tests/UserTests.cs @@ -2,8 +2,6 @@ using BuberDinner.Domain.User.Entities; using BuberDinner.Domain.User.ValueObjects; -using FunctionalDDD.Domain; -using FunctionalDDD.Results.Errors; #pragma warning disable IDE0007 // Use var keyword public class UserTests @@ -17,16 +15,14 @@ public class UserTests public void Required_parameters_are_validated(string field) { // Arrange - UserId? id = field == nameof(User.Id) ? default : UserId.New("xavierjohn2023").Value; - FirstName? firstName = field == nameof(User.FirstName) ? default : FirstName.New("Xavier").Value; - LastName? lastName = field == nameof(User.LastName) ? default : LastName.New("John").Value; - EmailAddress? email = field == nameof(User.Email) ? default : EmailAddress.New("xavier@somewhere.com").Value; - Password? password = field == nameof(User.Password) ? default : Password.New("you can't crack this.").Value; + UserId? id = field == nameof(User.Id) ? default : UserId.TryCreate("xavierjohn2023").Value; + FirstName? firstName = field == nameof(User.FirstName) ? default : FirstName.TryCreate("Xavier").Value; + LastName? lastName = field == nameof(User.LastName) ? default : LastName.TryCreate("John").Value; + EmailAddress? email = field == nameof(User.Email) ? default : EmailAddress.TryCreate("xavier@somewhere.com").Value; + Password? password = field == nameof(User.Password) ? default : Password.TryCreate("you can't crack this.").Value; // Act -#pragma warning disable CS8604 // Possible null reference argument. - var userResult = User.New(id, firstName, lastName, email, password); -#pragma warning restore CS8604 // Possible null reference argument. + var userResult = User.TryCreate(id!, firstName!, lastName!, email!, password!); // Assert userResult.IsFailure.Should().BeTrue(); @@ -39,8 +35,8 @@ public void Required_parameters_are_validated(string field) public void Different_passwords_are_not_the_same() { // Arrange - Password pwd1 = Password.New("Hello").Value; - Password pwd2 = Password.New("There").Value; + Password pwd1 = Password.TryCreate("Hello").Value; + Password pwd2 = Password.TryCreate("There").Value; // Act bool result1 = pwd1 == pwd2; @@ -53,11 +49,11 @@ public void Different_passwords_are_not_the_same() } [Fact] - public void Two_passwords_of_the_same_content_are_equal() + public void Two_passwords_with_the_same_content_are_equal() { // Arrange - Password pwd1 = Password.New("Hello").Value; - Password pwd2 = Password.New("Hello").Value; + Password pwd1 = Password.TryCreate("Hello").Value; + Password pwd2 = Password.TryCreate("Hello").Value; // Act bool result1 = pwd1 == pwd2; diff --git a/Infrastructure/src/Persistence/Dto/MenuDto.cs b/Infrastructure/src/Persistence/Dto/MenuDto.cs index c5e4ef9..e583f4b 100644 --- a/Infrastructure/src/Persistence/Dto/MenuDto.cs +++ b/Infrastructure/src/Persistence/Dto/MenuDto.cs @@ -36,13 +36,13 @@ public static MenuDto ToDto(this Menu menu) => public static Menu? ToMenu(this MenuDto? menuDto) => menuDto is null ? null - : Menu.New( - MenuId.New(Guid.Parse(menuDto.Id)).Value, - Name.New(menuDto.Name).Value, - Description.New(menuDto.Description).Value, + : Menu.TryCreate( + MenuId.TryCreate(Guid.Parse(menuDto.Id)).Value, + Name.TryCreate(menuDto.Name).Value, + Description.TryCreate(menuDto.Description).Value, menuDto.AverageRating, menuDto.Sections.Select(sectionDto => sectionDto.ToMenuSection()!).ToList(), - HostId.New(menuDto.HostId).Value, - menuDto.DinnerIds.Select(dinnerId => DinnerId.New(dinnerId).Value).ToList(), - menuDto.MenuReviewIds.Select(menuReviewId => MenuReviewId.New(menuReviewId).Value).ToList()).Value; + HostId.TryCreate(menuDto.HostId).Value, + menuDto.DinnerIds.Select(dinnerId => DinnerId.TryCreate(dinnerId).Value).ToList(), + menuDto.MenuReviewIds.Select(menuReviewId => MenuReviewId.TryCreate(menuReviewId).Value).ToList()).Value; } diff --git a/Infrastructure/src/Persistence/Dto/MenuISectionDto.cs b/Infrastructure/src/Persistence/Dto/MenuISectionDto.cs index 3b62946..f70173a 100644 --- a/Infrastructure/src/Persistence/Dto/MenuISectionDto.cs +++ b/Infrastructure/src/Persistence/Dto/MenuISectionDto.cs @@ -26,9 +26,9 @@ public static MenuSectionDto ToDto(this MenuSection menuSection) => public static MenuSection? ToMenuSection(this MenuSectionDto? menuSectionDto) => menuSectionDto is null ? null - : MenuSection.New( - MenuSectionId.New(menuSectionDto.Id).Value, - Name.New(menuSectionDto.Name).Value, - Description.New(menuSectionDto.Description).Value, + : MenuSection.TryCreate( + MenuSectionId.TryCreate(menuSectionDto.Id).Value, + Name.TryCreate(menuSectionDto.Name).Value, + Description.TryCreate(menuSectionDto.Description).Value, menuSectionDto.Items.Select(itemDto => itemDto.ToMenuItem()!).ToList()).Value; } diff --git a/Infrastructure/src/Persistence/Dto/MenuItemDto.cs b/Infrastructure/src/Persistence/Dto/MenuItemDto.cs index b4373a7..095f3df 100644 --- a/Infrastructure/src/Persistence/Dto/MenuItemDto.cs +++ b/Infrastructure/src/Persistence/Dto/MenuItemDto.cs @@ -24,8 +24,8 @@ public static MenuItemDto ToDto(this MenuItem menuItem) => public static MenuItem? ToMenuItem(this MenuItemDto? menuItemDto) => menuItemDto is null ? null - : MenuItem.New( - MenuItemId.New(menuItemDto.Id).Value, - Name.New(menuItemDto.Name).Value, - Description.New(menuItemDto.Description).Value).Value; + : MenuItem.TryCreate( + MenuItemId.TryCreate(menuItemDto.Id).Value, + Name.TryCreate(menuItemDto.Name).Value, + Description.TryCreate(menuItemDto.Description).Value).Value; } diff --git a/Infrastructure/src/Persistence/Dto/UserDto.cs b/Infrastructure/src/Persistence/Dto/UserDto.cs index bc1a381..118a459 100644 --- a/Infrastructure/src/Persistence/Dto/UserDto.cs +++ b/Infrastructure/src/Persistence/Dto/UserDto.cs @@ -4,7 +4,6 @@ namespace BuberDinner.Infrastructure.Persistence.Dto; using BuberDinner.Domain.User.Entities; using BuberDinner.Domain.User.ValueObjects; -using FunctionalDDD.Domain; public class UserDto { @@ -30,10 +29,10 @@ public static UserDto ToDto(this User user) => public static User? ToUser(this UserDto? userDto) => userDto is null ? null - : User.New( - UserId.New(userDto.Id).Value, - FirstName.New(userDto.FirstName).Value, - LastName.New(userDto.LastName).Value, - EmailAddress.New(userDto.Email).Value, - Password.New(userDto.Password).Value).Value; + : User.TryCreate( + UserId.TryCreate(userDto.Id).Value, + FirstName.TryCreate(userDto.FirstName).Value, + LastName.TryCreate(userDto.LastName).Value, + EmailAddress.TryCreate(userDto.Email).Value, + Password.TryCreate(userDto.Password).Value).Value; } diff --git a/Infrastructure/tests/MenuRepositoryTests.cs b/Infrastructure/tests/MenuRepositoryTests.cs index ce8ee85..37c0762 100644 --- a/Infrastructure/tests/MenuRepositoryTests.cs +++ b/Infrastructure/tests/MenuRepositoryTests.cs @@ -24,26 +24,26 @@ public async Task Can_read_and_write_Menu_from_storage() MenuCosmosDbRepository rep = new( _cosmosDbFixture.CosmosClient, new MenuCosmosDbContainerSettings()); - MenuId menuId = MenuId.New("2F45ACF9-6E51-4DC7-8732-DBE7F260E955").Value; - Name name = Name.New("Menu Name").Value; - Description description = Description.New("Menu Description").Value; - HostId hostId = HostId.New("2F45ACF9-6E51-4DC7-8732-DBE7F260E955").Value; + MenuId menuId = MenuId.TryCreate("2F45ACF9-6E51-4DC7-8732-DBE7F260E955").Value; + Name name = Name.TryCreate("Menu Name").Value; + Description description = Description.TryCreate("Menu Description").Value; + HostId hostId = HostId.TryCreate("2F45ACF9-6E51-4DC7-8732-DBE7F260E955").Value; decimal? averageRating = 3.8m; - MenuSectionId sectionId = MenuSectionId.New("2F45ACF9-6E51-4DC7-8732-DBE7F260E956").Value; - Name sectionName = Name.New("Section Name").Value; - Description sectionDescription = Description.New("Section Description").Value; - MenuItemId itemId = MenuItemId.New("2F45ACF9-6E51-4DC7-8732-DBE7F260E957").Value; - Name itemName = Name.New("Item Name").Value; - Description itemDescription = Description.New("Item Description").Value; - MenuItem item = MenuItem.New(itemId, itemName, itemDescription).Value; - MenuSection section = MenuSection.New( + MenuSectionId sectionId = MenuSectionId.TryCreate("2F45ACF9-6E51-4DC7-8732-DBE7F260E956").Value; + Name sectionName = Name.TryCreate("Section Name").Value; + Description sectionDescription = Description.TryCreate("Section Description").Value; + MenuItemId itemId = MenuItemId.TryCreate("2F45ACF9-6E51-4DC7-8732-DBE7F260E957").Value; + Name itemName = Name.TryCreate("Item Name").Value; + Description itemDescription = Description.TryCreate("Item Description").Value; + MenuItem item = MenuItem.TryCreate(itemId, itemName, itemDescription).Value; + MenuSection section = MenuSection.TryCreate( sectionId, sectionName, sectionDescription, new List() { item }).Value; - DinnerId dinnerId = DinnerId.New("2F45ACF9-6E51-4DC7-8732-DBE7F260E958").Value; - MenuReviewId menuReviewId = MenuReviewId.New("2F45ACF9-6E51-4DC7-8732-DBE7F260E959").Value; - Menu menu = Menu.New( + DinnerId dinnerId = DinnerId.TryCreate("2F45ACF9-6E51-4DC7-8732-DBE7F260E958").Value; + MenuReviewId menuReviewId = MenuReviewId.TryCreate("2F45ACF9-6E51-4DC7-8732-DBE7F260E959").Value; + Menu menu = Menu.TryCreate( menuId, name, description, diff --git a/Infrastructure/tests/UserRespositoryTests.cs b/Infrastructure/tests/UserRespositoryTests.cs index 5506abf..2d0f9a8 100644 --- a/Infrastructure/tests/UserRespositoryTests.cs +++ b/Infrastructure/tests/UserRespositoryTests.cs @@ -3,7 +3,6 @@ using BuberDinner.Domain.User.Entities; using BuberDinner.Domain.User.ValueObjects; using BuberDinner.Infrastructure.Persistence.Cosmos; -using FunctionalDDD.Domain; using Xunit.Categories; [Category("ComponentTests")] @@ -19,12 +18,12 @@ public async Task Can_read_and_write_User_from_storage() { // Arrange UserCosmosDbRepository rep = new(_cosmosDbFixture.CosmosClient, new UserCosmosDbContainerSettings()); - var userId = UserId.New("xavierjohn2023").Value; - var firstName = FirstName.New("Xavier").Value; - var lastName = LastName.New("John").Value; - var email = EmailAddress.New("xavier@somewhere.com").Value; - var password = Password.New("Amiko1232!").Value; - User user = User.New(userId, firstName, lastName, email, password).Value; + var userId = UserId.TryCreate("xavierjohn2023").Value; + var firstName = FirstName.TryCreate("Xavier").Value; + var lastName = LastName.TryCreate("John").Value; + var email = EmailAddress.TryCreate("xavier@somewhere.com").Value; + var password = Password.TryCreate("Amiko1232!").Value; + User user = User.TryCreate(userId, firstName, lastName, email, password).Value; // Act