From 2b30e1a03c9893e30c47637e0d4f9e4edf2ebcd6 Mon Sep 17 00:00:00 2001 From: Jonathan Bourdon Date: Wed, 31 Jul 2024 23:29:26 -0400 Subject: [PATCH] Split creators out of identity --- Directory.Packages.props | 2 +- .../Constants/CommonFileNames.cs | 1 - .../Behaviours/AuthorizationBehaviour.cs | 94 +-- .../Common/Behaviours/LoggingBehaviour.cs | 16 +- .../Common/Behaviours/PerformanceBehaviour.cs | 5 +- .../Interfaces/IAzureBlobStorageService.cs | 3 +- .../Common/Interfaces/IIdentityService.cs | 24 +- src/Application/Common/Interfaces/IUser.cs | 2 +- src/Application/Common/Models/RoleModel.cs | 2 +- src/Application/Common/Models/UserModel.cs | 32 +- .../Commands/ConfirmStripeTransaction.cs | 2 +- .../Commands/CreateSessionCheckoutCommand.cs | 19 +- .../Stripe/Queries/GetMyLastReceipt.cs | 16 +- src/Application/Users/Commands/CreateUser.cs | 4 +- .../Commands/UpdateCurrentUserCommand.cs | 34 +- .../Users/Commands/UploadBannerPicture.cs | 47 -- .../Users/Commands/UploadProfilePicture.cs | 33 +- .../Users/Commands/UploadWebsiteIcon.cs | 50 -- .../Users/Models/ProfileColorsModel.cs | 9 - .../Users/Models/SocialNetworksModel.cs | 13 - .../Users/Models/StoredDataUrlsModel.cs | 8 - .../Queries/GetCurrentUser/GetCurrentUser.cs | 40 +- .../GetCurrentUserProfilePicture.cs | 12 +- .../Users/Queries/GetCurrentUser/UserDto.cs | 31 +- .../Users/Queries/GetUser/GetUser.cs | 46 -- .../Users/Queries/GetUser/GetUserById.cs | 23 + .../Queries/GetUser/GetUserByUserName.cs | 23 + .../Users/Queries/GetUser/UserDto.cs | 30 +- src/Domain/Common/BaseAuditableEntity.cs | 8 +- src/Domain/Entities/UserTransaction.cs | 2 +- .../AzureBlob/AzureBlobStorageService.cs | 17 +- .../Data/ApplicationDbContext.cs | 8 +- .../Data/ApplicationDbContextInitializer.cs | 7 +- .../ApplicationUserConfiguration.cs | 26 - .../AuditableEntityInterceptor.cs | 4 +- src/Infrastructure/DependencyInjection.cs | 5 +- .../Identity/ApplicationRole.cs | 4 +- .../Identity/ApplicationUser.cs | 27 +- .../Identity/ApplicationUserManager.cs | 20 +- .../Identity/IdentityResultExtensions.cs | 3 +- .../Identity/IdentityService.cs | 325 +++------- .../Identity/OwnedEntities/ProfileColors.cs | 9 - .../Identity/OwnedEntities/SocialNetworks.cs | 13 - .../Identity/OwnedEntities/StoredDataUrls.cs | 10 - src/Infrastructure/Identity/RoleService.cs | 6 +- src/Infrastructure/Infrastructure.csproj | 23 +- ...0240418221249_InitialMigration.Designer.cs | 334 ----------- ...0422173330_AddUserTransactions.Designer.cs | 383 ------------ .../20240422173330_AddUserTransactions.cs | 52 -- ...ddIsConfirmedToUserTransaction.Designer.cs | 387 ------------ ...5020920_AddIsConfirmedToUserTransaction.cs | 29 - ...9215538_AddMoreInformationToTransaction.cs | 106 ---- ...000806_AddSocialNetworksToUser.Designer.cs | 469 --------------- .../20240612000806_AddSocialNetworksToUser.cs | 52 -- ...6_AddMissingInformationsToUser.Designer.cs | 497 ---------------- ...0630001806_AddMissingInformationsToUser.cs | 95 --- ...3057_AddMoreInformationsToUser.Designer.cs | 557 ----------------- ...0240630163057_AddMoreInformationsToUser.cs | 77 --- ...701072549_AddPortraitUrlToUser.Designer.cs | 500 ---------------- .../20240701072549_AddPortraitUrlToUser.cs | 28 - ...02055858_AddCreatorAliasTouser.Designer.cs | 560 ----------------- .../20240702055858_AddCreatorAliasTouser.cs | 28 - ...240705010235_RemovePortraitUrl.Designer.cs | 560 ----------------- .../20240705010235_RemovePortraitUrl.cs | 28 - .../20240721045147_AddAlias.Designer.cs | 563 ------------------ .../Migrations/20240721045147_AddAlias.cs | 28 - ...35_MadeOptional_StoredDataUrls.Designer.cs | 563 ------------------ ...40721063535_MadeOptional_StoredDataUrls.cs | 78 --- ....cs => 20240802044736_Initial.Designer.cs} | 190 +++--- ...Migration.cs => 20240802044736_Initial.cs} | 79 ++- .../ApplicationDbContextModelSnapshot.cs | 301 +++------- src/Infrastructure/Stripe/StripeService.cs | 3 - src/Infrastructure/Utils/GenerateJwtToken.cs | 6 +- src/Infrastructure/Utils/KnownClaims.cs | 4 +- src/Web/Controllers/GoogleController.cs | 4 +- src/Web/DependencyInjection.cs | 2 - src/Web/Endpoints/GetMyUser.cs | 3 +- src/Web/Endpoints/UpdateMyUser.cs | 24 +- src/Web/Endpoints/Users.cs | 12 +- .../Contents/Data/ContentDbContext.cs | 39 +- src/Web/Features/Contents/Data/Creator.cs | 48 ++ .../Contents/Handlers/ChangeBanner.cs | 49 ++ .../Contents/Handlers/ChangeColors.cs | 71 +++ .../Contents/Handlers/CreateContent.cs | 6 +- .../Contents/Handlers/CreateCreator.cs | 53 ++ .../Contents/Handlers/GetCreatorByAlias.cs | 31 +- .../Contents/Handlers/GetCreatorById.cs | 47 ++ .../20240718034516_Initial.Designer.cs | 59 -- .../Migrations/20240718034516_Initial.cs | 43 -- ..._AddMultipleMediaUrlsToContent.Designer.cs | 59 -- ...725022229_AddMultipleMediaUrlsToContent.cs | 42 -- .../20240802044656_Initial.Designer.cs | 214 +++++++ .../Migrations/20240802044656_Initial.cs | 78 +++ .../ContentDbContextModelSnapshot.cs | 157 ++++- .../Features/Messages/Handlers/AddMessage.cs | 4 +- .../20240721041322_Initial.Designer.cs | 67 --- .../20240721064224_ChangedAuthorDefinition.cs | 60 -- ....cs => 20240802044717_Initial.Designer.cs} | 4 +- ...2_Initial.cs => 20240802044717_Initial.cs} | 4 +- src/Web/Services/CurrentUser.cs | 7 +- src/Web/TestDataSeeder.cs | 62 +- src/Web/Web.csproj | 5 + tests/Application.FunctionalTests/Testing.cs | 32 +- .../Common/Behaviours/RequestLoggerTests.cs | 4 +- .../Common/Mappings/MappingTests.cs | 2 - 105 files changed, 1497 insertions(+), 7490 deletions(-) delete mode 100644 src/Application/Users/Commands/UploadBannerPicture.cs delete mode 100644 src/Application/Users/Commands/UploadWebsiteIcon.cs delete mode 100644 src/Application/Users/Models/ProfileColorsModel.cs delete mode 100644 src/Application/Users/Models/SocialNetworksModel.cs delete mode 100644 src/Application/Users/Models/StoredDataUrlsModel.cs delete mode 100644 src/Application/Users/Queries/GetUser/GetUser.cs create mode 100644 src/Application/Users/Queries/GetUser/GetUserById.cs create mode 100644 src/Application/Users/Queries/GetUser/GetUserByUserName.cs delete mode 100644 src/Infrastructure/Data/Configurations/ApplicationUserConfiguration.cs delete mode 100644 src/Infrastructure/Identity/OwnedEntities/ProfileColors.cs delete mode 100644 src/Infrastructure/Identity/OwnedEntities/SocialNetworks.cs delete mode 100644 src/Infrastructure/Identity/OwnedEntities/StoredDataUrls.cs delete mode 100644 src/Infrastructure/Migrations/20240418221249_InitialMigration.Designer.cs delete mode 100644 src/Infrastructure/Migrations/20240422173330_AddUserTransactions.Designer.cs delete mode 100644 src/Infrastructure/Migrations/20240422173330_AddUserTransactions.cs delete mode 100644 src/Infrastructure/Migrations/20240425020920_AddIsConfirmedToUserTransaction.Designer.cs delete mode 100644 src/Infrastructure/Migrations/20240425020920_AddIsConfirmedToUserTransaction.cs delete mode 100644 src/Infrastructure/Migrations/20240509215538_AddMoreInformationToTransaction.cs delete mode 100644 src/Infrastructure/Migrations/20240612000806_AddSocialNetworksToUser.Designer.cs delete mode 100644 src/Infrastructure/Migrations/20240612000806_AddSocialNetworksToUser.cs delete mode 100644 src/Infrastructure/Migrations/20240630001806_AddMissingInformationsToUser.Designer.cs delete mode 100644 src/Infrastructure/Migrations/20240630001806_AddMissingInformationsToUser.cs delete mode 100644 src/Infrastructure/Migrations/20240630163057_AddMoreInformationsToUser.Designer.cs delete mode 100644 src/Infrastructure/Migrations/20240630163057_AddMoreInformationsToUser.cs delete mode 100644 src/Infrastructure/Migrations/20240701072549_AddPortraitUrlToUser.Designer.cs delete mode 100644 src/Infrastructure/Migrations/20240701072549_AddPortraitUrlToUser.cs delete mode 100644 src/Infrastructure/Migrations/20240702055858_AddCreatorAliasTouser.Designer.cs delete mode 100644 src/Infrastructure/Migrations/20240702055858_AddCreatorAliasTouser.cs delete mode 100644 src/Infrastructure/Migrations/20240705010235_RemovePortraitUrl.Designer.cs delete mode 100644 src/Infrastructure/Migrations/20240705010235_RemovePortraitUrl.cs delete mode 100644 src/Infrastructure/Migrations/20240721045147_AddAlias.Designer.cs delete mode 100644 src/Infrastructure/Migrations/20240721045147_AddAlias.cs delete mode 100644 src/Infrastructure/Migrations/20240721063535_MadeOptional_StoredDataUrls.Designer.cs delete mode 100644 src/Infrastructure/Migrations/20240721063535_MadeOptional_StoredDataUrls.cs rename src/Infrastructure/Migrations/{20240509215538_AddMoreInformationToTransaction.Designer.cs => 20240802044736_Initial.Designer.cs} (77%) rename src/Infrastructure/Migrations/{20240418221249_InitialMigration.cs => 20240802044736_Initial.cs} (69%) create mode 100644 src/Web/Features/Contents/Data/Creator.cs create mode 100644 src/Web/Features/Contents/Handlers/ChangeBanner.cs create mode 100644 src/Web/Features/Contents/Handlers/ChangeColors.cs create mode 100644 src/Web/Features/Contents/Handlers/CreateCreator.cs create mode 100644 src/Web/Features/Contents/Handlers/GetCreatorById.cs delete mode 100644 src/Web/Features/Contents/Migrations/20240718034516_Initial.Designer.cs delete mode 100644 src/Web/Features/Contents/Migrations/20240718034516_Initial.cs delete mode 100644 src/Web/Features/Contents/Migrations/20240725022229_AddMultipleMediaUrlsToContent.Designer.cs delete mode 100644 src/Web/Features/Contents/Migrations/20240725022229_AddMultipleMediaUrlsToContent.cs create mode 100644 src/Web/Features/Contents/Migrations/20240802044656_Initial.Designer.cs create mode 100644 src/Web/Features/Contents/Migrations/20240802044656_Initial.cs delete mode 100644 src/Web/Features/Messages/Migrations/20240721041322_Initial.Designer.cs delete mode 100644 src/Web/Features/Messages/Migrations/20240721064224_ChangedAuthorDefinition.cs rename src/Web/Features/Messages/Migrations/{20240721064224_ChangedAuthorDefinition.Designer.cs => 20240802044717_Initial.Designer.cs} (95%) rename src/Web/Features/Messages/Migrations/{20240721041322_Initial.cs => 20240802044717_Initial.cs} (93%) diff --git a/Directory.Packages.props b/Directory.Packages.props index 42adba5..00e2212 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -7,7 +7,7 @@ - + diff --git a/src/Application/AzureBlobStorage/Constants/CommonFileNames.cs b/src/Application/AzureBlobStorage/Constants/CommonFileNames.cs index b6d44aa..6a37a08 100644 --- a/src/Application/AzureBlobStorage/Constants/CommonFileNames.cs +++ b/src/Application/AzureBlobStorage/Constants/CommonFileNames.cs @@ -4,5 +4,4 @@ public static class CommonFileNames { public static string ProfilePicture = "profilePicture"; public static string BannerPicture = "bannerPicture"; - public static string WebsiteIcon = "websiteIcon"; } diff --git a/src/Application/Common/Behaviours/AuthorizationBehaviour.cs b/src/Application/Common/Behaviours/AuthorizationBehaviour.cs index 30de73f..8012cce 100644 --- a/src/Application/Common/Behaviours/AuthorizationBehaviour.cs +++ b/src/Application/Common/Behaviours/AuthorizationBehaviour.cs @@ -7,62 +7,74 @@ namespace Hutopy.Application.Common.Behaviours; public class AuthorizationBehaviour( IUser user, - IIdentityService identityService) + IIdentityService identityService) : IPipelineBehavior where TRequest : notnull { - public async Task Handle(TRequest request, RequestHandlerDelegate next, CancellationToken cancellationToken) + public async Task Handle(TRequest request, RequestHandlerDelegate next, + CancellationToken cancellationToken) { - var authorizeAttributes = request.GetType().GetCustomAttributes(); + var authorizeAttributes = request + .GetType() + .GetCustomAttributes() + .ToArray(); - if (authorizeAttributes.Any()) + if (authorizeAttributes.Length == 0) { - // Must be authenticated user - if (user.Id == null) + return await next(); + } + + if (user.Id is null) + { + throw new UnauthorizedAccessException(); + } + + // Role-based authorization + var authorizeAttributesWithRoles = authorizeAttributes + .Where(a => !string.IsNullOrWhiteSpace(a.Roles)) + .ToArray(); + + if (authorizeAttributesWithRoles.Length != 0) + { + var authorized = false; + + foreach (var roles in authorizeAttributesWithRoles.Select(a => a.Roles.Split(','))) { - throw new UnauthorizedAccessException(); - } - - // Role-based authorization - var authorizeAttributesWithRoles = authorizeAttributes.Where(a => !string.IsNullOrWhiteSpace(a.Roles)); - - if (authorizeAttributesWithRoles.Any()) - { - var authorized = false; - - foreach (var roles in authorizeAttributesWithRoles.Select(a => a.Roles.Split(','))) + foreach (var role in roles) { - foreach (var role in roles) + var isInRole = await identityService.IsInRoleAsync(user.Id.Value, role.Trim()); + if (isInRole) { - var isInRole = await identityService.IsInRoleAsync(user.Id, role.Trim()); - if (isInRole) - { - authorized = true; - break; - } + authorized = true; + break; } } - - // Must be a member of at least one role in roles - if (!authorized) - { - throw new ForbiddenAccessException(); - } } - // Policy-based authorization - var authorizeAttributesWithPolicies = authorizeAttributes.Where(a => !string.IsNullOrWhiteSpace(a.Policy)); - if (authorizeAttributesWithPolicies.Any()) + // Must be a member of at least one role in roles + if (!authorized) { - foreach (var policy in authorizeAttributesWithPolicies.Select(a => a.Policy)) - { - var authorized = await identityService.AuthorizeAsync(user.Id, policy); + throw new ForbiddenAccessException(); + } + } - if (!authorized) - { - throw new ForbiddenAccessException(); - } - } + // Policy-based authorization + var authorizeAttributesWithPolicies = authorizeAttributes + .Where(a => !string.IsNullOrWhiteSpace(a.Policy)) + .ToArray(); + + if (authorizeAttributesWithPolicies.Length == 0) + { + return await next(); + } + + foreach (var policy in authorizeAttributesWithPolicies.Select(a => a.Policy)) + { + var authorized = await identityService.AuthorizeAsync(user.Id.Value, policy); + + if (!authorized) + { + throw new ForbiddenAccessException(); } } diff --git a/src/Application/Common/Behaviours/LoggingBehaviour.cs b/src/Application/Common/Behaviours/LoggingBehaviour.cs index 07814ca..def9dca 100644 --- a/src/Application/Common/Behaviours/LoggingBehaviour.cs +++ b/src/Application/Common/Behaviours/LoggingBehaviour.cs @@ -5,9 +5,9 @@ using Microsoft.Extensions.Logging; namespace Hutopy.Application.Common.Behaviours; public class LoggingBehaviour( - ILogger logger, - IUser user, - IIdentityService identityService) + ILogger logger, + IUser user, + IIdentityService identityService) : IRequestPreProcessor where TRequest : notnull { @@ -16,15 +16,15 @@ public class LoggingBehaviour( public async Task Process(TRequest request, CancellationToken cancellationToken) { var requestName = typeof(TRequest).Name; - var userId = user.Id ?? string.Empty; string? userName = string.Empty; - if (!string.IsNullOrEmpty(userId)) + if (user.Id.HasValue) { - userName = await identityService.GetUserNameAsync(userId); + userName = await identityService.GetUserNameAsync(user.Id.Value); } - _logger.LogInformation("Hutopy Request: {Name} {@UserId} {@UserName} {@Request}", - requestName, userId, userName, request); + _logger.LogInformation( + "Hutopy Request: {Name} {@UserId} {@UserName} {@Request}", + requestName, user.Id ?? Guid.Empty, userName, request); } } diff --git a/src/Application/Common/Behaviours/PerformanceBehaviour.cs b/src/Application/Common/Behaviours/PerformanceBehaviour.cs index ada438a..20a82a2 100644 --- a/src/Application/Common/Behaviours/PerformanceBehaviour.cs +++ b/src/Application/Common/Behaviours/PerformanceBehaviour.cs @@ -26,13 +26,12 @@ public class PerformanceBehaviour( if (elapsedMilliseconds <= 500) return response; var requestName = typeof(TRequest).Name; - var userId = user.Id ?? string.Empty; var userName = string.Empty; - if (!string.IsNullOrEmpty(userId)) userName = await identityService.GetUserNameAsync(userId); + if (user.Id.HasValue) userName = await identityService.GetUserNameAsync(user.Id.Value); logger.LogWarning("Hutopy Long Running Request: {Name} ({ElapsedMilliseconds} milliseconds) {@UserId} {@UserName} {@Request}", - requestName, elapsedMilliseconds, userId, userName, request); + requestName, elapsedMilliseconds, user.Id ?? Guid.Empty, userName, request); return response; } diff --git a/src/Application/Common/Interfaces/IAzureBlobStorageService.cs b/src/Application/Common/Interfaces/IAzureBlobStorageService.cs index e0aa991..83537e9 100644 --- a/src/Application/Common/Interfaces/IAzureBlobStorageService.cs +++ b/src/Application/Common/Interfaces/IAzureBlobStorageService.cs @@ -2,6 +2,7 @@ public interface IAzureBlobStorageService { - Task UploadFileAsync(string containerName, string blobName, MemoryStream memoryStream, string contentType, CancellationToken ct = default); + Task UploadFileAsync(string containerName, string blobName, Stream stream, string contentType, + CancellationToken ct = default); Task DownloadFileAsync(string containerName, string blobName, CancellationToken ct = default); } diff --git a/src/Application/Common/Interfaces/IIdentityService.cs b/src/Application/Common/Interfaces/IIdentityService.cs index e780b94..3ebbfb3 100644 --- a/src/Application/Common/Interfaces/IIdentityService.cs +++ b/src/Application/Common/Interfaces/IIdentityService.cs @@ -1,29 +1,27 @@ -using Google.Apis.Oauth2.v2.Data; -using Hutopy.Application.Common.Models; +using Hutopy.Application.Common.Models; namespace Hutopy.Application.Common.Interfaces; public interface IIdentityService { - Task> CreateUserAsync(Userinfo userInfo); - - Task> CreateUserAsync(string email, string userName, string firstName, string lastName, + Task> CreateUserAsync( + string email, + string userName, + string firstName, + string lastName, string password); Task GetCurrentUserAsync(); - Task UpdateCurrentUserBannerPictureUrlAsync(string url); - Task UpdateCurrentUserProfilePictureUrlAsync(string url); - Task UpdateCurrentUserWebsiteIconUrlAsync(string url); - Task> UpdateCurrentUserAsync(UserModel userModel); + Task UpdateCurrentUserPortraitUrlAsync(string url); + Task> UpdateCurrentUserAsync(UserModel userModel); Task> GetCurrentUserRolesAsync(); Task FindUserByIdAsync(string id); - Task FindUserByCreatorAliasAsync(string creatorAlias, CancellationToken cancellationToken); Task FindUserByEmailAsync(string email); Task GetUserByUserNameAsync(string userName); Task LoginAsync(string email, string password); - Task IsInRoleAsync(string userId, string role); - Task AuthorizeAsync(string userId, string policyName); - Task GetUserNameAsync(string userId); + Task IsInRoleAsync(Guid userId, string role); + Task AuthorizeAsync(Guid userId, string policyName); + Task GetUserNameAsync(Guid userId); Task AddRoleAsync(string userId, string role); Task DeleteUserAsync(string userId); diff --git a/src/Application/Common/Interfaces/IUser.cs b/src/Application/Common/Interfaces/IUser.cs index f6112a1..ede555b 100644 --- a/src/Application/Common/Interfaces/IUser.cs +++ b/src/Application/Common/Interfaces/IUser.cs @@ -2,5 +2,5 @@ public interface IUser { - string? Id { get; } + Guid? Id { get; } } diff --git a/src/Application/Common/Models/RoleModel.cs b/src/Application/Common/Models/RoleModel.cs index ed49feb..5c1c786 100644 --- a/src/Application/Common/Models/RoleModel.cs +++ b/src/Application/Common/Models/RoleModel.cs @@ -2,6 +2,6 @@ namespace Hutopy.Application.Common.Models; public class RoleModel { - public string? Id { get; set; } + public Guid Id { get; set; } public string? Name { get; set; } } diff --git a/src/Application/Common/Models/UserModel.cs b/src/Application/Common/Models/UserModel.cs index f67d8a9..b38e4b4 100644 --- a/src/Application/Common/Models/UserModel.cs +++ b/src/Application/Common/Models/UserModel.cs @@ -1,26 +1,16 @@ -using Hutopy.Application.Users.Models; - namespace Hutopy.Application.Common.Models; public class UserModel { - public string Id { get; set; } = string.Empty; - public string? CreatorAlias { get; set; } - public string UserName { get; set; } = string.Empty; - public string? Alias { get; set; } - public string FirstName { get; set; } = string.Empty; - public string LastName { get; set; } = string.Empty; - public string Occupation { get; set; } = string.Empty; - public string Email { get; init; } = string.Empty; - public string PhoneNumber { get; init; } = string.Empty; - public string BirthDate { get; init; } = string.Empty; - public string Country { get; init; } = string.Empty; - public string City { get; init; } = string.Empty; - public string Address { get; init; } = string.Empty; - public string About { get; init; } = string.Empty; - public string Description { get; init; } = string.Empty; - public SocialNetworksModel SocialNetworks { get; init; } = new(); - public ProfileColorsModel ProfileColors { get; init; } = new(); - public StoredDataUrlsModel StoredDataUrls { get; init; } = new(); - public string ProfilePictureUrl { get; set; } = string.Empty; + public Guid Id { get; set; } + public string UserName { get; init; } = null!; + public string? Alias { get; init; } + public string? PortraitUrl { get; init; } + public string? FirstName { get; init; } + public string? LastName { get; init; } + public string? Occupation { get; init; } + public string? Email { get; init; } + public string? PhoneNumber { get; init; } + public string? BirthDate { get; init; } + public string? Address { get; init; } } diff --git a/src/Application/Stripe/Commands/ConfirmStripeTransaction.cs b/src/Application/Stripe/Commands/ConfirmStripeTransaction.cs index 0c74658..e287b45 100644 --- a/src/Application/Stripe/Commands/ConfirmStripeTransaction.cs +++ b/src/Application/Stripe/Commands/ConfirmStripeTransaction.cs @@ -50,7 +50,7 @@ public class ConfirmStripeTransactionCommandHandler( { public async Task Handle(ConfirmStripeTransactionCommand request, CancellationToken cancellationToken) { - var lastTransaction = await dbContext.UserTransactions.OrderBy(x => x.Created).LastAsync(cancellationToken); + var lastTransaction = await dbContext.UserTransactions.OrderBy(x => x.CreatedAt).LastAsync(cancellationToken); var stripeConfirmation = stripeService.ValidateTransaction(request); if (stripeConfirmation.Succeeded) diff --git a/src/Application/Stripe/Commands/CreateSessionCheckoutCommand.cs b/src/Application/Stripe/Commands/CreateSessionCheckoutCommand.cs index 681c4d8..80249d3 100644 --- a/src/Application/Stripe/Commands/CreateSessionCheckoutCommand.cs +++ b/src/Application/Stripe/Commands/CreateSessionCheckoutCommand.cs @@ -2,30 +2,37 @@ using Hutopy.Domain.Entities; namespace Hutopy.Application.Stripe.Commands; + public record CreateSessionCheckoutCommand : IRequest { - public required string CreatorId { get; init; } + public required Guid CreatorId { get; init; } public required int Amount { get; init; } public string Currency { get; init; } = "CAD"; public string TipMessage { get; init; } = string.Empty; } public class CreateSessionCheckoutCommandHandler( - IApplicationDbContext dbContext, + IApplicationDbContext dbContext, IStripeService stripeService - ) +) : IRequestHandler { public async Task Handle(CreateSessionCheckoutCommand request, CancellationToken cancellationToken) { - var stripeSecret = await stripeService.CreateCheckoutSession(request.Amount, request.CreatorId, request.Currency); + var stripeSecret = await stripeService.CreateCheckoutSession( + request.Amount, + request.CreatorId.ToString(), + request.Currency); // ReSharper disable once PossibleLossOfFraction decimal priceInDollars = (request.Amount / 100); - + var userTransaction = new UserTransaction { - Currency = request.Currency, Amount = priceInDollars, TipMessage = request.TipMessage, ApplicationUserId = request.CreatorId + Currency = request.Currency, + Amount = priceInDollars, + TipMessage = request.TipMessage, + ApplicationUserId = request.CreatorId }; await dbContext.UserTransactions.AddAsync(userTransaction, cancellationToken); diff --git a/src/Application/Stripe/Queries/GetMyLastReceipt.cs b/src/Application/Stripe/Queries/GetMyLastReceipt.cs index b8a0602..c4feb05 100644 --- a/src/Application/Stripe/Queries/GetMyLastReceipt.cs +++ b/src/Application/Stripe/Queries/GetMyLastReceipt.cs @@ -4,25 +4,23 @@ namespace Hutopy.Application.Stripe.Queries; public record GetMyLastReceiptQuery : IRequest { + public Guid CreatorId { get; set; } public string Email { get; set; } = string.Empty; - public string CreatorId { get; set; } = string.Empty; }; public class GetMyLastReceiptQueryHandler( IApplicationDbContext dbContext - ) +) : IRequestHandler { public async Task Handle(GetMyLastReceiptQuery request, CancellationToken cancellationToken) { - var lastTransaction = await dbContext.UserTransactions.OrderBy(x => x.Created) - .LastOrDefaultAsync(x => x.ApplicationUserId == request.CreatorId && x.StripeBillingDetailEmail == request.Email, + var lastTransaction = await dbContext.UserTransactions.OrderBy(x => x.CreatedAt) + .LastOrDefaultAsync( + x => x.ApplicationUserId == request.CreatorId && x.StripeBillingDetailEmail == request.Email, cancellationToken); - - var receiptUrl = new MyLastReceiptDto - { - ReceiptUrl = lastTransaction?.StripeReceiptUrl ?? "", - }; + + var receiptUrl = new MyLastReceiptDto { ReceiptUrl = lastTransaction?.StripeReceiptUrl ?? "", }; return receiptUrl; } diff --git a/src/Application/Users/Commands/CreateUser.cs b/src/Application/Users/Commands/CreateUser.cs index 703066c..d84b69b 100644 --- a/src/Application/Users/Commands/CreateUser.cs +++ b/src/Application/Users/Commands/CreateUser.cs @@ -28,8 +28,10 @@ public class CreateUserCommandHandler : IRequestHandler { - public required string FirstName { get; init; } - public required string LastName { get; init; } - public required string Occupation { get; init; } - public required string PhoneNumber { get; init; } - public required string BirthDate { get; init; } - public required string Country { get; init; } - public required string City { get; init; } - public required string Address { get; init; } - public required string About { get; init; } - public required string Description { get; init; } - public required SocialNetworksModel SocialNetworks { get; init; } - public required ProfileColorsModel ProfileColors { get; init; } + public required string? Alias { get; init; } + public required string? FirstName { get; init; } + public required string? LastName { get; init; } + public required string? Occupation { get; init; } + public required string? BirthDate { get; init; } + public required string? Country { get; init; } + public required string? City { get; init; } + public required string? Address { get; init; } - [NotMapped] private class Mapping : Profile { @@ -32,8 +26,11 @@ public class UpdateCurrentUserCommand : IRequest } } -public class UpdateCurrentUserCommandHandler(IApplicationDbContext context, IIdentityService identityService, IMapper mapper) : - IRequestHandler +public class UpdateCurrentUserCommandHandler( + IApplicationDbContext context, + IIdentityService identityService, + IMapper mapper) + : IRequestHandler { public async Task Handle(UpdateCurrentUserCommand request, CancellationToken cancellationToken) { @@ -43,12 +40,11 @@ public class UpdateCurrentUserCommandHandler(IApplicationDbContext context, IIde var userModel = mapper.Map(request); userModel.Id = identityUser.Id; - + var result = await identityService.UpdateCurrentUserAsync(userModel); await context.SaveChangesAsync(cancellationToken); - + return result.Succeeded ? Results.Ok(result.GetValueOrDefault()) : Results.Problem(result.GetErrorsAsString()); } } - diff --git a/src/Application/Users/Commands/UploadBannerPicture.cs b/src/Application/Users/Commands/UploadBannerPicture.cs deleted file mode 100644 index 63573fb..0000000 --- a/src/Application/Users/Commands/UploadBannerPicture.cs +++ /dev/null @@ -1,47 +0,0 @@ -using Hutopy.Application.AzureBlobStorage.Constants; -using Hutopy.Application.Common.Interfaces; -using Hutopy.Application.Utils; -using Microsoft.AspNetCore.Http; - -namespace Hutopy.Application.Users.Commands; - -/// -/// Upload a banner picture. If the user has the url already, set the BannerPictureUrl in the user only without upload. -/// -public class UploadBannerPictureCommand : IRequest -{ - public required MemoryStream BannerPicture { get; init; } - public string BannerPictureUrl { get; init; } = string.Empty; -} - -public class UploadBannerPictureCommandHandler(IHttpContextAccessor contextAccessor, IIdentityService identityService, IAzureBlobStorageService azureBlobStorageService) : IRequestHandler -{ - public async Task Handle(UploadBannerPictureCommand request, CancellationToken cancellationToken) - { - // If an url to the picture is provided, use it right away and don't upload anything. - if (!string.IsNullOrEmpty(request.BannerPictureUrl)) - { - await identityService.UpdateCurrentUserBannerPictureUrlAsync(request.BannerPictureUrl); - return Results.Ok(request.BannerPictureUrl); - } - - var contentType = contextAccessor.EnsureContentType(); - - var identityUser = await identityService.GetCurrentUserAsync(); - var currentUserId = new Guid(identityUser?.Id ?? "").ToString(); - - var blobName = $"{currentUserId}/{SubDirectoryNames.Profile}/{CommonFileNames.BannerPicture}"; - - var url = await azureBlobStorageService.UploadFileAsync( - ContainerNames.Users, - blobName, - request.BannerPicture, - contentType, - cancellationToken); - - await identityService.UpdateCurrentUserBannerPictureUrlAsync(url); - - return Results.Ok(url); - } -} - diff --git a/src/Application/Users/Commands/UploadProfilePicture.cs b/src/Application/Users/Commands/UploadProfilePicture.cs index 431e014..cbf4b00 100644 --- a/src/Application/Users/Commands/UploadProfilePicture.cs +++ b/src/Application/Users/Commands/UploadProfilePicture.cs @@ -10,38 +10,29 @@ namespace Hutopy.Application.Users.Commands; /// public class UploadProfilePictureCommand : IRequest { - public required MemoryStream ProfilePicture { get; init; } - public string ProfilePictureUrl { get; init; } = string.Empty; + public required IFormFile File { get; init; } } -public class UploadProfilePictureCommandHandler(IHttpContextAccessor contextAccessor, IIdentityService identityService, IAzureBlobStorageService azureBlobStorageService) : IRequestHandler +public class UploadProfilePictureCommandHandler( + IHttpContextAccessor contextAccessor, + IIdentityService identityService, + IAzureBlobStorageService azureBlobStorageService) : IRequestHandler { public async Task Handle(UploadProfilePictureCommand request, CancellationToken ct) { - // If an url to the picture is provided, use it right away and don't upload anything. - if (!string.IsNullOrEmpty(request.ProfilePictureUrl)) - { - await identityService.UpdateCurrentUserProfilePictureUrlAsync(request.ProfilePictureUrl); - return Results.Ok(request.ProfilePictureUrl); - } - var contentType = contextAccessor.EnsureContentType(); - + var identityUser = await identityService.GetCurrentUserAsync(); - var currentUserId = new Guid(identityUser?.Id ?? "").ToString(); - - var blobName = $"{currentUserId}/{SubDirectoryNames.Profile}/{CommonFileNames.ProfilePicture}"; - + var url = await azureBlobStorageService.UploadFileAsync( - ContainerNames.Users, - blobName, - request.ProfilePicture, + ContainerNames.Users, + $"{identityUser.Id}/{SubDirectoryNames.Profile}/{CommonFileNames.ProfilePicture}", + request.File.OpenReadStream(), contentType, ct); - await identityService.UpdateCurrentUserProfilePictureUrlAsync(url); - + await identityService.UpdateCurrentUserPortraitUrlAsync(url); + return Results.Ok(url); } } - diff --git a/src/Application/Users/Commands/UploadWebsiteIcon.cs b/src/Application/Users/Commands/UploadWebsiteIcon.cs deleted file mode 100644 index 2e74eda..0000000 --- a/src/Application/Users/Commands/UploadWebsiteIcon.cs +++ /dev/null @@ -1,50 +0,0 @@ -using Hutopy.Application.AzureBlobStorage.Constants; -using Hutopy.Application.Common.Interfaces; -using Hutopy.Application.Utils; -using Microsoft.AspNetCore.Http; - -namespace Hutopy.Application.Users.Commands; - -/// -/// Upload a website icon. If the user has the url already, set the WebsitePictureUrl in the user only without upload. -/// -public class UploadWebsiteIconCommand : IRequest -{ - public required MemoryStream WebsiteIcon { get; init; } - - public string WebsitePictureUrl { get; init; } = string.Empty; -} - -public class UploadWebsiteIconCommandHandler( - IHttpContextAccessor contextAccessor, - IIdentityService identityService, - IAzureBlobStorageService azureBlobStorageService) : IRequestHandler -{ - public async Task Handle(UploadWebsiteIconCommand request, CancellationToken ct) - { - // If an url to the picture is provided, use it right away and don't upload anything. - if (!string.IsNullOrEmpty(request.WebsitePictureUrl)) - { - await identityService.UpdateCurrentUserWebsiteIconUrlAsync(request.WebsitePictureUrl); - return Results.Ok(request.WebsitePictureUrl); - } - - var contentType = contextAccessor.EnsureContentType(); - - var identityUser = await identityService.GetCurrentUserAsync(); - var currentUserId = new Guid(identityUser?.Id ?? "").ToString(); - - var blobName = $"{currentUserId}/{SubDirectoryNames.Profile}/{CommonFileNames.WebsiteIcon}"; - - var url = await azureBlobStorageService.UploadFileAsync( - ContainerNames.Users, - blobName, - request.WebsiteIcon, - contentType, - ct); - - await identityService.UpdateCurrentUserWebsiteIconUrlAsync(url); - - return Results.Ok(request.WebsitePictureUrl); - } -} diff --git a/src/Application/Users/Models/ProfileColorsModel.cs b/src/Application/Users/Models/ProfileColorsModel.cs deleted file mode 100644 index 04baadb..0000000 --- a/src/Application/Users/Models/ProfileColorsModel.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace Hutopy.Application.Users.Models; - -public class ProfileColorsModel -{ - public string BannerTop { get; init; } = String.Empty; - public string BannerBottom { get; init; } = String.Empty; - public string Accent { get; init; } = String.Empty; - public string Menu { get; init; } = String.Empty; -} diff --git a/src/Application/Users/Models/SocialNetworksModel.cs b/src/Application/Users/Models/SocialNetworksModel.cs deleted file mode 100644 index 19a2f02..0000000 --- a/src/Application/Users/Models/SocialNetworksModel.cs +++ /dev/null @@ -1,13 +0,0 @@ -namespace Hutopy.Application.Users.Models; - -public class SocialNetworksModel -{ - public string FacebookUrl { get; init; } = string.Empty; - public string InstagramUrl { get; init; } = string.Empty; - public string XUrl { get; init; } = string.Empty; - public string LinkedInUrl { get; init; } = string.Empty; - public string TikTokUrl { get; init; } = string.Empty; - public string YoutubeUrl { get; init; } = string.Empty; - public string RedditUrl { get; init; } = string.Empty; - public string YourWebsiteUrl { get; init; } = string.Empty; -} diff --git a/src/Application/Users/Models/StoredDataUrlsModel.cs b/src/Application/Users/Models/StoredDataUrlsModel.cs deleted file mode 100644 index 06eb528..0000000 --- a/src/Application/Users/Models/StoredDataUrlsModel.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace Hutopy.Application.Users.Models; - -public class StoredDataUrlsModel -{ - public string? BannerPictureUrl { get; set; } - public string? ProfilePictureUrl { get; set; } - public string? WebsiteIconUrl { get; set; } -} diff --git a/src/Application/Users/Queries/GetCurrentUser/GetCurrentUser.cs b/src/Application/Users/Queries/GetCurrentUser/GetCurrentUser.cs index 4429bed..18e3f8e 100644 --- a/src/Application/Users/Queries/GetCurrentUser/GetCurrentUser.cs +++ b/src/Application/Users/Queries/GetCurrentUser/GetCurrentUser.cs @@ -11,15 +11,16 @@ public class GetCurrentUserQueryHandler( ) : IRequestHandler { - public async Task Handle(GetCurrentUserQuery request, CancellationToken cancellationToken) + public async Task Handle(GetCurrentUserQuery request, CancellationToken cancellationToken) { - var identityUser = await identityService.GetCurrentUserAsync(); - var currentUserId = Guid.Parse(identityUser!.Id!); + var userModel = await identityService.GetCurrentUserAsync(); + if (userModel is null) return null; + var transactions = await context .UserTransactions - .Where(x => x.ApplicationUserId == currentUserId.ToString()) - .OrderBy(x => x.LastModified) + .Where(x => x.ApplicationUserId == userModel.Id) + .OrderBy(x => x.LastModifiedAt) .ProjectTo(mapper.ConfigurationProvider) .Where(x => x.IsConfirmed == true) .ToListAsync(cancellationToken); @@ -28,24 +29,17 @@ public class GetCurrentUserQueryHandler( var user = new UserDto { - Id = currentUserId, - Alias = identityUser.Alias, - FirstName = identityUser.FirstName, - LastName = identityUser.LastName, - UserName = identityUser.UserName, - CreatorAlias= identityUser.CreatorAlias, - Occupation = identityUser.Occupation, - PhoneNumber = identityUser.PhoneNumber, - Email = identityUser.Email, - BirthDate = identityUser.BirthDate, - Country = identityUser.Country, - City = identityUser.City, - Address = identityUser.Address, - About = identityUser.About, - Description = identityUser.Description, - SocialNetworks = identityUser.SocialNetworks, - ProfileColors = identityUser.ProfileColors, - StoredDataUrls = identityUser.StoredDataUrls, + Id = userModel.Id, + Alias = userModel.Alias, + PortraitUrl = userModel.PortraitUrl, + FirstName = userModel.FirstName, + LastName = userModel.LastName, + UserName = userModel.UserName, + Occupation = userModel.Occupation, + PhoneNumber = userModel.PhoneNumber, + Email = userModel.Email, + BirthDate = userModel.BirthDate, + Address = userModel.Address, UserTransactions = transactions, TotalBalance = transactions.Sum(x => x.Amount), UserRoles = roles, diff --git a/src/Application/Users/Queries/GetCurrentUser/GetCurrentUserProfilePicture.cs b/src/Application/Users/Queries/GetCurrentUser/GetCurrentUserProfilePicture.cs index cb4e6b4..f598887 100644 --- a/src/Application/Users/Queries/GetCurrentUser/GetCurrentUserProfilePicture.cs +++ b/src/Application/Users/Queries/GetCurrentUser/GetCurrentUserProfilePicture.cs @@ -8,16 +8,16 @@ public record GetCurrentUserProfilePictureQuery : IRequest; public class GetCurrentUserProfilePictureQueryHandler( IIdentityService identityService, IAzureBlobStorageService azureBlobStorageService - ) +) : IRequestHandler { public async Task Handle(GetCurrentUserProfilePictureQuery request, CancellationToken cancellationToken) { var identityUser = await identityService.GetCurrentUserAsync(); - var currentUserId = new Guid(identityUser?.Id ?? ""); - - var blobName = $"{currentUserId.ToString()}/{SubDirectoryNames.Profile}/{CommonFileNames.ProfilePicture}"; - - return await azureBlobStorageService.DownloadFileAsync(ContainerNames.Users, blobName); + + return await azureBlobStorageService.DownloadFileAsync( + ContainerNames.Users, + $"{identityUser.Id.ToString()}/{SubDirectoryNames.Profile}/{CommonFileNames.ProfilePicture}", + cancellationToken); } } diff --git a/src/Application/Users/Queries/GetCurrentUser/UserDto.cs b/src/Application/Users/Queries/GetCurrentUser/UserDto.cs index 3560de2..689c411 100644 --- a/src/Application/Users/Queries/GetCurrentUser/UserDto.cs +++ b/src/Application/Users/Queries/GetCurrentUser/UserDto.cs @@ -1,28 +1,19 @@ -using Hutopy.Application.Users.Models; - namespace Hutopy.Application.Users.Queries.GetCurrentUser; public class UserDto { public Guid Id { get; init; } - public string? Alias { get; init; } - public required string FirstName { get; init; } - public required string LastName { get; init; } - public string? CreatorAlias { get; set; } - public string UserName { get; init; } = string.Empty; - public string Occupation { get; init; } = string.Empty; - public string Email { get; init; } = string.Empty; - public string PhoneNumber { get; init; } = string.Empty; - public string BirthDate { get; init; } = string.Empty; - public string Country { get; init; } = string.Empty; - public string City { get; init; } = string.Empty; - public string Address { get; init; } = string.Empty; - public string About { get; init; } = string.Empty; - public string Description { get; init; } = string.Empty; - public SocialNetworksModel SocialNetworks { get; init; } = new(); - public ProfileColorsModel ProfileColors { get; init; } = new(); - public StoredDataUrlsModel StoredDataUrls { get; init; } = new(); - public List UserTransactions { get; init; } = []; public IList UserRoles { get; init; } = []; + public string UserName { get; init; } = null!; + public string? Alias { get; init; } + public string? PortraitUrl { get; init; } + public string? FirstName { get; init; } + public string? LastName { get; init; } + public string? Occupation { get; init; } + public string? Email { get; init; } + public string? PhoneNumber { get; init; } + public string? BirthDate { get; init; } + public string? Address { get; init; } + public List UserTransactions { get; init; } = []; public required decimal TotalBalance { get; init; } } diff --git a/src/Application/Users/Queries/GetUser/GetUser.cs b/src/Application/Users/Queries/GetUser/GetUser.cs deleted file mode 100644 index 3b36caa..0000000 --- a/src/Application/Users/Queries/GetUser/GetUser.cs +++ /dev/null @@ -1,46 +0,0 @@ -using Hutopy.Application.Common.Interfaces; -using Hutopy.Application.Common.Models; - -namespace Hutopy.Application.Users.Queries.GetUser; - -public record GetUserQuery : IRequest -{ - public string? UserId { get; set; } = string.Empty; - public string? UserName { get; set; } = string.Empty; -}; - -public class GetUserQueryHandler( - IIdentityService identityService - ) - : IRequestHandler -{ - public async Task Handle(GetUserQuery request, CancellationToken cancellationToken) - { - UserModel? identityUser = null; - - if (request.UserId != string.Empty) - { - identityUser = await identityService.FindUserByIdAsync(request.UserId); - - } - - if (request.UserName != string.Empty) - { - identityUser = await identityService.GetUserByUserNameAsync(request.UserName); - } - - var user = new UserDto - { - Id = identityUser?.Id ?? string.Empty, - FirstName = identityUser?.FirstName ?? string.Empty, - LastName = identityUser?.LastName ?? string.Empty, - UserName = identityUser?.UserName ?? string.Empty, - Occupation = identityUser?.Occupation ?? string.Empty, - SocialNetworks = identityUser?.SocialNetworks ?? new(), - ProfileColors = identityUser?.ProfileColors ?? new(), - StoredDataUrls = identityUser?.StoredDataUrls ?? new(), - }; - - return user; - } -} diff --git a/src/Application/Users/Queries/GetUser/GetUserById.cs b/src/Application/Users/Queries/GetUser/GetUserById.cs new file mode 100644 index 0000000..1128cfc --- /dev/null +++ b/src/Application/Users/Queries/GetUser/GetUserById.cs @@ -0,0 +1,23 @@ +using Hutopy.Application.Common.Interfaces; + +namespace Hutopy.Application.Users.Queries.GetUser; + +public record GetUserByIdQuery : IRequest +{ + public required string UserId { get; init; } +} + +public class GetUserByIdHandler( + IIdentityService identityService + ) + : IRequestHandler +{ + public async Task Handle(GetUserByIdQuery query, CancellationToken cancellationToken) + { + var user = await identityService.FindUserByIdAsync(query.UserId); + + if (user is null) throw new InvalidOperationException(); + + return user.ToDto(); + } +} diff --git a/src/Application/Users/Queries/GetUser/GetUserByUserName.cs b/src/Application/Users/Queries/GetUser/GetUserByUserName.cs new file mode 100644 index 0000000..131ac8b --- /dev/null +++ b/src/Application/Users/Queries/GetUser/GetUserByUserName.cs @@ -0,0 +1,23 @@ +using Hutopy.Application.Common.Interfaces; + +namespace Hutopy.Application.Users.Queries.GetUser; + +public record GetUserByUserNameQuery : IRequest +{ + public required string UserName { get; init; } +}; + +public class GetUserByUserNameQueryHandler( + IIdentityService identityService +) + : IRequestHandler +{ + public async Task Handle(GetUserByUserNameQuery query, CancellationToken cancellationToken) + { + var user = await identityService.GetUserByUserNameAsync(query.UserName); + + if (user is null) throw new InvalidOperationException(); + + return user.ToDto(); + } +} diff --git a/src/Application/Users/Queries/GetUser/UserDto.cs b/src/Application/Users/Queries/GetUser/UserDto.cs index 6c1dc13..86ce3d4 100644 --- a/src/Application/Users/Queries/GetUser/UserDto.cs +++ b/src/Application/Users/Queries/GetUser/UserDto.cs @@ -1,17 +1,25 @@ -using Hutopy.Application.Users.Models; +using Hutopy.Application.Common.Models; namespace Hutopy.Application.Users.Queries.GetUser; public class UserDto { - public required string Id { get; init; } - public required string FirstName { get; init; } - public required string LastName { get; init; } - public string CreatorAlias { get; set; } - public required string UserName { get; init; } = String.Empty; - public required string Occupation { get; init; } = String.Empty; - - public SocialNetworksModel SocialNetworks { get; init; } = new(); - public ProfileColorsModel ProfileColors { get; init; } = new(); - public StoredDataUrlsModel StoredDataUrls { get; init; } = new(); + public required Guid Id { get; init; } + public required string UserName { get; init; } + public string? FirstName { get; init; } + public string? LastName { get; init; } + public string? Occupation { get; init; } +} + +public static class UserDtoExtensions +{ + public static UserDto ToDto(this UserModel model) => + new() + { + Id = model.Id, + FirstName = model.FirstName, + LastName = model.LastName, + UserName = model.UserName, + Occupation = model.Occupation + }; } diff --git a/src/Domain/Common/BaseAuditableEntity.cs b/src/Domain/Common/BaseAuditableEntity.cs index f1da955..617d876 100644 --- a/src/Domain/Common/BaseAuditableEntity.cs +++ b/src/Domain/Common/BaseAuditableEntity.cs @@ -2,11 +2,11 @@ public abstract class BaseAuditableEntity : BaseEntity { - public DateTimeOffset Created { get; set; } + public DateTimeOffset CreatedAt { get; set; } - public string? CreatedBy { get; set; } + public Guid? CreatedBy { get; set; } - public DateTimeOffset LastModified { get; set; } + public DateTimeOffset LastModifiedAt { get; set; } - public string? LastModifiedBy { get; set; } + public Guid? LastModifiedBy { get; set; } } diff --git a/src/Domain/Entities/UserTransaction.cs b/src/Domain/Entities/UserTransaction.cs index 78e32d4..b7df7da 100644 --- a/src/Domain/Entities/UserTransaction.cs +++ b/src/Domain/Entities/UserTransaction.cs @@ -7,7 +7,7 @@ public class UserTransaction : BaseAuditableEntity public string TipMessage { get; set; } = string.Empty; // Foreign key to ApplicationUser - public required string ApplicationUserId { get; set; } + public required Guid ApplicationUserId { get; set; } public bool IsConfirmed { get; set; } public string StripeEventId { get; set; } = string.Empty; public string StripeChargeId { get; set; } = string.Empty; diff --git a/src/Infrastructure/AzureBlob/AzureBlobStorageService.cs b/src/Infrastructure/AzureBlob/AzureBlobStorageService.cs index 7887cef..9fee071 100644 --- a/src/Infrastructure/AzureBlob/AzureBlobStorageService.cs +++ b/src/Infrastructure/AzureBlob/AzureBlobStorageService.cs @@ -23,21 +23,21 @@ public class AzureBlobStorageService : IAzureBlobStorageService /// /// Upload a file to microsoft azure blob storage. /// - /// The blob name (path within the container, include the file name). /// The name of the container where the file is stored. - /// The memory stream containing the image. + /// The blob name (path within the container, include the file name). + /// /// The content type. /// The cancellation token /// - public async Task UploadFileAsync(string containerName, string blobName, MemoryStream memoryStream, + public async Task UploadFileAsync(string containerName, string blobName, Stream stream, string contentType, CancellationToken ct = default) { // Read the file stream into a memory stream to determine the length // WATCH FOR MEMORY USAGE USING THE MEMORY STREAM. - memoryStream.Position = 0; + stream.Position = 0; // Check if the file size exceeds the maximum upload size - if (memoryStream.Length > _maxUploadSize) + if (stream.Length > _maxUploadSize) { _logger.LogError( $"Blob storage: File size exceeds the maximum allowed size of {_maxUploadSize} bytes."); @@ -46,7 +46,7 @@ public class AzureBlobStorageService : IAzureBlobStorageService } // Validate content type - if (!ContentTypes.IsAllowed(contentType, memoryStream)) + if (!ContentTypes.IsAllowed(contentType, stream)) { _logger.LogError( $"Blob storage: Unsupported file type {contentType}. Only PNG and JPEG are allowed."); @@ -71,7 +71,7 @@ public class AzureBlobStorageService : IAzureBlobStorageService // Upload the file var response = await blobClient.UploadAsync( - memoryStream, + stream, new BlobUploadOptions { HttpHeaders = blobHttpHeaders }, ct); @@ -89,7 +89,7 @@ public class AzureBlobStorageService : IAzureBlobStorageService blobName, containerName, contentType, - memoryStream.Length, + stream.Length, fileUri ); @@ -128,6 +128,7 @@ public class AzureBlobStorageService : IAzureBlobStorageService // Download the blob to a stream BlobDownloadInfo download = await blobClient.DownloadAsync(ct); + MemoryStream memoryStream = new(); await download.Content.CopyToAsync(memoryStream, ct); memoryStream.Position = 0; // Ensure the stream is at the beginning diff --git a/src/Infrastructure/Data/ApplicationDbContext.cs b/src/Infrastructure/Data/ApplicationDbContext.cs index 21b06a4..a8a5d4f 100644 --- a/src/Infrastructure/Data/ApplicationDbContext.cs +++ b/src/Infrastructure/Data/ApplicationDbContext.cs @@ -7,13 +7,9 @@ using Microsoft.EntityFrameworkCore; namespace Hutopy.Infrastructure.Data { - public class ApplicationDbContext : IdentityDbContext, IApplicationDbContext + public class ApplicationDbContext(DbContextOptions options) + : IdentityDbContext(options), IApplicationDbContext { - public ApplicationDbContext(DbContextOptions options) - : base(options) - { - } - public DbSet FutureCreators => Set(); public DbSet UserTransactions => Set(); diff --git a/src/Infrastructure/Data/ApplicationDbContextInitializer.cs b/src/Infrastructure/Data/ApplicationDbContextInitializer.cs index ef35783..ff313b4 100644 --- a/src/Infrastructure/Data/ApplicationDbContextInitializer.cs +++ b/src/Infrastructure/Data/ApplicationDbContextInitializer.cs @@ -1,4 +1,5 @@ using Hutopy.Domain.Constants; +using Hutopy.Infrastructure.Identity; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Identity; using Microsoft.EntityFrameworkCore; @@ -24,7 +25,7 @@ public static class InitializerExtensions public class ApplicationDbContextInitializer( ILogger logger, ApplicationDbContext context, - RoleManager roleManager) + RoleManager roleManager) { public async Task InitialiseAsync() { @@ -54,13 +55,13 @@ public class ApplicationDbContextInitializer( private async Task TrySeedAsync() { - var administratorRole = new IdentityRole(Roles.Administrator); + var administratorRole = new ApplicationRole(Roles.Administrator); if (roleManager.Roles.All(r => r.Name != administratorRole.Name)) { await roleManager.CreateAsync(administratorRole); } - var roleCreator = new IdentityRole(Roles.Creator); + var roleCreator = new ApplicationRole(Roles.Creator); if (roleManager.Roles.All(r => r.Name != roleCreator.Name)) { await roleManager.CreateAsync(roleCreator); diff --git a/src/Infrastructure/Data/Configurations/ApplicationUserConfiguration.cs b/src/Infrastructure/Data/Configurations/ApplicationUserConfiguration.cs deleted file mode 100644 index b3a3735..0000000 --- a/src/Infrastructure/Data/Configurations/ApplicationUserConfiguration.cs +++ /dev/null @@ -1,26 +0,0 @@ -using Hutopy.Infrastructure.Identity; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Metadata.Builders; - -namespace Hutopy.Infrastructure.Data.Configurations; - -public class ApplicationUserConfiguration : IEntityTypeConfiguration -{ - public void Configure(EntityTypeBuilder builder) - { - // Relationship between ApplicationUser and SocialNetworks - builder - .OwnsOne(u => u.SocialNetworks) - .ToTable($"{nameof(ApplicationUser)}_SocialNetworks"); - - // Relationship between ApplicationUser and ProfileColors - builder - .OwnsOne(u => u.ProfileColors) - .ToTable($"{nameof(ApplicationUser)}_ProfileColors"); - - // Relationship between ApplicationUser and StoredDataUrls - builder - .OwnsOne(u => u.StoredDataUrls) - .ToTable($"{nameof(ApplicationUser)}_StoredDataUrls"); - } -} diff --git a/src/Infrastructure/Data/Interceptors/AuditableEntityInterceptor.cs b/src/Infrastructure/Data/Interceptors/AuditableEntityInterceptor.cs index f38d7b5..b1d7157 100644 --- a/src/Infrastructure/Data/Interceptors/AuditableEntityInterceptor.cs +++ b/src/Infrastructure/Data/Interceptors/AuditableEntityInterceptor.cs @@ -36,10 +36,10 @@ public class AuditableEntityInterceptor( if (entry.State == EntityState.Added) { entry.Entity.CreatedBy = user.Id; - entry.Entity.Created = utcNow; + entry.Entity.CreatedAt = utcNow; } entry.Entity.LastModifiedBy = user.Id; - entry.Entity.LastModified = utcNow; + entry.Entity.LastModifiedAt = utcNow; } } } diff --git a/src/Infrastructure/DependencyInjection.cs b/src/Infrastructure/DependencyInjection.cs index c4abf71..f7c3525 100644 --- a/src/Infrastructure/DependencyInjection.cs +++ b/src/Infrastructure/DependencyInjection.cs @@ -1,5 +1,4 @@ -using System; -using Hutopy.Application.Common.Interfaces; +using Hutopy.Application.Common.Interfaces; using Hutopy.Domain.Constants; using Hutopy.Infrastructure.AzureBlob; using Hutopy.Infrastructure.Data; @@ -45,7 +44,7 @@ public static class DependencyInjection services .AddIdentityCore() .AddUserManager() - .AddRoles() + .AddRoles() .AddEntityFrameworkStores() .AddApiEndpoints() .AddSignInManager>() diff --git a/src/Infrastructure/Identity/ApplicationRole.cs b/src/Infrastructure/Identity/ApplicationRole.cs index eba9904..4f90614 100644 --- a/src/Infrastructure/Identity/ApplicationRole.cs +++ b/src/Infrastructure/Identity/ApplicationRole.cs @@ -2,6 +2,8 @@ namespace Hutopy.Infrastructure.Identity; -public class ApplicationRole : IdentityRole +public class ApplicationRole : IdentityRole { + public ApplicationRole() { } + public ApplicationRole(string roleName) : base(roleName) { } } diff --git a/src/Infrastructure/Identity/ApplicationUser.cs b/src/Infrastructure/Identity/ApplicationUser.cs index 9b7ebdd..7d52e10 100644 --- a/src/Infrastructure/Identity/ApplicationUser.cs +++ b/src/Infrastructure/Identity/ApplicationUser.cs @@ -1,22 +1,15 @@ -using Hutopy.Infrastructure.Identity.OwnedEntities; +using System.ComponentModel.DataAnnotations; using Microsoft.AspNetCore.Identity; namespace Hutopy.Infrastructure.Identity; -public class ApplicationUser : IdentityUser -{ - public string? Alias { get; set; } - public required string FirstName { get; set; } - public required string LastName { get; set; } - public string? CreatorAlias { get; set; } - public string Occupation { get; set; } = string.Empty; - public string BirthDate { get; set; } = string.Empty; - public string Country { get; set; } = string.Empty; - public string City { get; set; } = string.Empty; - public string Address { get; set; } = string.Empty; - public string About { get; set; } = string.Empty; - public string Description { get; set; } = string.Empty; - public SocialNetworks SocialNetworks { get; set; } = new(); - public ProfileColors ProfileColors { get; set; } = new(); - public StoredDataUrls StoredDataUrls { get; set; } = new(); +public class ApplicationUser : IdentityUser +{ + [MaxLength(255)] public string? Alias { get; set; } + [MaxLength(255)] public string? FirstName { get; set; } + [MaxLength(255)] public string? LastName { get; set; } + [MaxLength(255)] public string? Occupation { get; set; } + [MaxLength(255)] public string? BirthDate { get; set; } + [MaxLength(255)] public string? Address { get; set; } + [MaxLength(255)] public string? PortraitUrl { get; set; } } diff --git a/src/Infrastructure/Identity/ApplicationUserManager.cs b/src/Infrastructure/Identity/ApplicationUserManager.cs index 8125aae..1799bbc 100644 --- a/src/Infrastructure/Identity/ApplicationUserManager.cs +++ b/src/Infrastructure/Identity/ApplicationUserManager.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Threading; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Identity; -using Microsoft.EntityFrameworkCore; +using Microsoft.AspNetCore.Identity; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; @@ -30,17 +25,4 @@ public sealed class ApplicationUserManager( services, logger) { - public async Task FindByCreatorAliasAsync(string creatorAlias, - CancellationToken cancellationToken = default) - { - ArgumentException.ThrowIfNullOrEmpty(creatorAlias); - ThrowIfDisposed(); - - var user = await Users.SingleOrDefaultAsync(u => EF.Functions.Like( - creatorAlias, - u.CreatorAlias), - cancellationToken: cancellationToken); - - return user; - } } diff --git a/src/Infrastructure/Identity/IdentityResultExtensions.cs b/src/Infrastructure/Identity/IdentityResultExtensions.cs index 0902e4f..630c372 100644 --- a/src/Infrastructure/Identity/IdentityResultExtensions.cs +++ b/src/Infrastructure/Identity/IdentityResultExtensions.cs @@ -1,5 +1,4 @@ -using System.Linq; -using Hutopy.Application.Common.Models; +using Hutopy.Application.Common.Models; using Microsoft.AspNetCore.Identity; namespace Hutopy.Infrastructure.Identity; diff --git a/src/Infrastructure/Identity/IdentityService.cs b/src/Infrastructure/Identity/IdentityService.cs index beaab6b..f853d1f 100644 --- a/src/Infrastructure/Identity/IdentityService.cs +++ b/src/Infrastructure/Identity/IdentityService.cs @@ -17,67 +17,39 @@ public class IdentityService( IAuthorizationService authorizationService, IHttpContextAccessor contextAccessor, IOptionsSnapshot jwtOptions - ) +) : IIdentityService { - public async Task GetUserNameAsync(string userId) + public async Task GetUserNameAsync(Guid userId) { - var user = await userManager.FindByIdAsync(userId); + var user = await userManager.FindByIdAsync(userId.ToString()); return user?.UserName; } - + public async Task GetUserByUserNameAsync(string userName) { var user = await userManager.FindByNameAsync(userName); - + if (user == null) return null; return new() { Id = user.Id, - CreatorAlias = user.CreatorAlias, - UserName = user.UserName ?? string.Empty, + UserName = user.UserName!, + PhoneNumber = user.PhoneNumber, + Email = user.Email, Alias = user.Alias, FirstName = user.FirstName, LastName = user.LastName, - Email = user.Email ?? string.Empty, Occupation = user.Occupation, - PhoneNumber = user.PhoneNumber ?? string.Empty, BirthDate = user.BirthDate, - Country = user.Country, - City = user.City, Address = user.Address, - About = user.About, - Description = user.Description, - SocialNetworks = new() - { - FacebookUrl = user.SocialNetworks.FacebookUrl, - InstagramUrl = user.SocialNetworks.InstagramUrl, - XUrl = user.SocialNetworks.XUrl, - LinkedInUrl = user.SocialNetworks.LinkedInUrl, - TikTokUrl = user.SocialNetworks.TikTokUrl, - YoutubeUrl = user.SocialNetworks.YoutubeUrl, - RedditUrl = user.SocialNetworks.RedditUrl, - YourWebsiteUrl = user.SocialNetworks.YourWebsiteUrl, - }, - ProfileColors = new() - { - BannerTop = user.ProfileColors.BannerTop, - BannerBottom = user.ProfileColors.BannerBottom, - Accent = user.ProfileColors.Accent, - Menu = user.ProfileColors.Menu - }, - StoredDataUrls = new() - { - ProfilePictureUrl = user.StoredDataUrls.ProfilePictureUrl, - BannerPictureUrl = user.StoredDataUrls.BannerPictureUrl, - WebsiteIconUrl = user.StoredDataUrls.WebsiteIconUrl, - } + PortraitUrl = user.PortraitUrl }; } - - public async Task> CreateUserAsync(Userinfo userInfo) + + public async Task> CreateUserAsync(Userinfo userInfo) { var applicationUser = new ApplicationUser { @@ -86,80 +58,83 @@ public class IdentityService( FirstName = userInfo.GivenName, LastName = userInfo.FamilyName }; - + var password = Guid.NewGuid().ToString("N")[..32]; var identityResult = await userManager.CreateAsync(applicationUser, password); var applicationResult = identityResult.ToApplicationResult(); - var result = new Result(applicationUser.Id, applicationResult.Succeeded, applicationResult.Errors); - + var result = new Result(applicationUser.Id, applicationResult.Succeeded, applicationResult.Errors); + return result; } - - public async Task> CreateUserAsync(string email, string userName, string firstName, string lastName, string password) + + public async Task> CreateUserAsync(string email, string userName, string firstName, string lastName, + string password) { var applicationUser = new ApplicationUser { - UserName = userName, - Email = email, - FirstName = firstName, - LastName = lastName + UserName = userName, Email = email, FirstName = firstName, LastName = lastName }; var response = await userManager.CreateAsync(applicationUser, password); - - var result = new Result(applicationUser.Id, response.Succeeded, response.ToApplicationResult().Errors); + + var result = new Result(applicationUser.Id, response.Succeeded, response.ToApplicationResult().Errors); return result; } - public async Task> UpdateCurrentUserAsync(UserModel userModel) + public async Task> UpdateCurrentUserAsync(UserModel userModel) { - var applicationUser = await userManager.FindByIdAsync(userModel.Id); + var applicationUser = await userManager.FindByIdAsync(userModel.Id.ToString()); - if (applicationUser is null) return Result.Failure("", new[] { "User not found." }); + if (applicationUser is null) return Result.Failure(Guid.Empty, new[] { "User not found." }); + applicationUser.Id = userModel.Id; + applicationUser.Email = userModel.Email; + applicationUser.PhoneNumber = userModel.PhoneNumber; + applicationUser.Alias = userModel.Alias; applicationUser.FirstName = userModel.FirstName; applicationUser.LastName = userModel.LastName; applicationUser.Occupation = userModel.Occupation; - applicationUser.PhoneNumber = userModel.PhoneNumber; applicationUser.BirthDate = userModel.BirthDate; - applicationUser.Country = userModel.Country; - applicationUser.City = userModel.City; applicationUser.Address = userModel.Address; - applicationUser.About = userModel.About; - applicationUser.Description = userModel.Description; - applicationUser.SocialNetworks = new() - { - FacebookUrl = userModel.SocialNetworks.FacebookUrl, - InstagramUrl = userModel.SocialNetworks.InstagramUrl, - XUrl = userModel.SocialNetworks.XUrl, - LinkedInUrl = userModel.SocialNetworks.LinkedInUrl, - TikTokUrl = userModel.SocialNetworks.TikTokUrl, - YoutubeUrl = userModel.SocialNetworks.YoutubeUrl, - RedditUrl = userModel.SocialNetworks.RedditUrl, - YourWebsiteUrl = userModel.SocialNetworks.YourWebsiteUrl - }; - applicationUser.ProfileColors = new() - { - BannerTop = userModel.ProfileColors.BannerTop, - BannerBottom = userModel.ProfileColors.BannerBottom, - Accent = userModel.ProfileColors.Accent, - Menu = userModel.ProfileColors.Menu - }; + applicationUser.PortraitUrl = userModel.PortraitUrl; var response = await userManager.UpdateAsync(applicationUser); var applicationResult = response.ToApplicationResult(); - var result = new Result(userModel.Id, applicationResult.Succeeded, + var result = new Result( + userModel.Id, + applicationResult.Succeeded, applicationResult.Errors); - + return result; } - + + + private static UserModel BuildModelFrom(ApplicationUser response) + { + var userModel = new UserModel + { + Id = response.Id, + UserName = response.UserName ?? string.Empty, + PhoneNumber = response.PhoneNumber ?? string.Empty, + Email = response.Email ?? string.Empty, + PortraitUrl = response.PortraitUrl, + Alias = response.Alias, + FirstName = response.FirstName, + LastName = response.LastName, + Occupation = response.Occupation, + BirthDate = response.BirthDate, + Address = response.Address, + }; + + return userModel; + } + public async Task FindUserByIdAsync(string id) { var user = await userManager.FindByIdAsync(id); @@ -170,64 +145,6 @@ public class IdentityService( return userModel; } - - public async Task FindUserByCreatorAliasAsync(string creatorAlias, CancellationToken cancellationToken = default) - { - var user = await userManager.FindByCreatorAliasAsync(creatorAlias, cancellationToken); - - if (user == null) return null; - - var userModel = BuildModelFrom(user); - - return userModel; - } - - private static UserModel BuildModelFrom(ApplicationUser response) - { - var userModel = new UserModel - { - Id = response.Id, - CreatorAlias = response.CreatorAlias, - UserName = response.UserName ?? string.Empty, - Alias = response.Alias, - FirstName = response.FirstName, - LastName = response.LastName, - Email = response.Email ?? string.Empty, - Occupation = response.Occupation, - PhoneNumber = response.PhoneNumber ?? string.Empty, - BirthDate = response.BirthDate, - Country = response.Country, - City = response.City, - Address = response.Address, - About = response.About, - Description = response.Description, - SocialNetworks = new() - { - FacebookUrl = response.SocialNetworks.FacebookUrl, - InstagramUrl = response.SocialNetworks.InstagramUrl, - XUrl = response.SocialNetworks.XUrl, - LinkedInUrl = response.SocialNetworks.LinkedInUrl, - TikTokUrl = response.SocialNetworks.TikTokUrl, - YoutubeUrl = response.SocialNetworks.YoutubeUrl, - RedditUrl = response.SocialNetworks.RedditUrl, - YourWebsiteUrl = response.SocialNetworks.YourWebsiteUrl, - }, - ProfileColors = new() - { - BannerTop = response.ProfileColors.BannerTop, - BannerBottom = response.ProfileColors.BannerBottom, - Accent = response.ProfileColors.Accent, - Menu = response.ProfileColors.Menu - }, - StoredDataUrls = new() - { - ProfilePictureUrl = response.StoredDataUrls.ProfilePictureUrl, - BannerPictureUrl = response.StoredDataUrls.BannerPictureUrl, - WebsiteIconUrl = response.StoredDataUrls.WebsiteIconUrl, - } - }; - return userModel; - } public async Task FindUserByEmailAsync(string email) { @@ -235,51 +152,9 @@ public class IdentityService( if (response == null) return null; - var userModel = new UserModel - { - Id = response.Id, - CreatorAlias = response.CreatorAlias, - UserName = response.UserName ?? string.Empty, - FirstName = response.FirstName, - LastName = response.LastName, - Email = response.Email ?? string.Empty, - Occupation = response.Occupation, - PhoneNumber = response.PhoneNumber ?? string.Empty, - BirthDate = response.BirthDate, - Country = response.Country, - City = response.City, - Address = response.Address, - About = response.About, - Description = response.Description, - SocialNetworks = new() - { - FacebookUrl = response.SocialNetworks.FacebookUrl, - InstagramUrl = response.SocialNetworks.InstagramUrl, - XUrl = response.SocialNetworks.XUrl, - LinkedInUrl = response.SocialNetworks.LinkedInUrl, - TikTokUrl = response.SocialNetworks.TikTokUrl, - YoutubeUrl = response.SocialNetworks.YoutubeUrl, - RedditUrl = response.SocialNetworks.RedditUrl, - YourWebsiteUrl = response.SocialNetworks.YourWebsiteUrl, - }, - ProfileColors = new() - { - BannerTop = response.ProfileColors.BannerTop, - BannerBottom = response.ProfileColors.BannerBottom, - Accent = response.ProfileColors.Accent, - Menu = response.ProfileColors.Menu - }, - StoredDataUrls = new() - { - ProfilePictureUrl = response.StoredDataUrls.ProfilePictureUrl, - BannerPictureUrl = response.StoredDataUrls.BannerPictureUrl, - WebsiteIconUrl = response.StoredDataUrls.WebsiteIconUrl, - } - }; - - return userModel; + return BuildModelFrom(response); } - + public async Task GetCurrentUserAsync() { var currentUserId = contextAccessor.HttpContext?.User.FindFirst(ClaimTypes.NameIdentifier)?.Value; @@ -291,69 +166,38 @@ public class IdentityService( return await FindUserByIdAsync(currentUserId); } - public async Task UpdateCurrentUserBannerPictureUrlAsync(string url) + public async Task UpdateCurrentUserPortraitUrlAsync(string url) { var userModel = await GetCurrentUserAsync(); - if (userModel is null) return Result.Failure(new[] { "User not found." }); - var applicationUser = await userManager.FindByIdAsync(userModel.Id); - if (applicationUser is null) return Result.Failure(new[] { "ApplicationUser not found." }); + var applicationUser = await userManager.FindByIdAsync(userModel.Id.ToString()); + if (applicationUser is null) return Result.Failure(["ApplicationUser not found."]); + + applicationUser.PortraitUrl = url; - applicationUser.StoredDataUrls.BannerPictureUrl = url; - var response = await userManager.UpdateAsync(applicationUser); return response.ToApplicationResult(); } - public async Task UpdateCurrentUserProfilePictureUrlAsync(string url) + public async Task IsInRoleAsync(Guid userId, string role) { - var userModel = await GetCurrentUserAsync(); - if (userModel is null) return Result.Failure(new[] { "User not found." }); - - var applicationUser = await userManager.FindByIdAsync(userModel.Id); - if (applicationUser is null) return Result.Failure(new[] { "ApplicationUser not found." }); - - applicationUser.StoredDataUrls.ProfilePictureUrl = url; - - var response = await userManager.UpdateAsync(applicationUser); - - return response.ToApplicationResult(); - } - - public async Task UpdateCurrentUserWebsiteIconUrlAsync(string url) - { - var userModel = await GetCurrentUserAsync(); - if (userModel is null) return Result.Failure(new[] { "User not found." }); - - var applicationUser = await userManager.FindByIdAsync(userModel.Id); - if (applicationUser is null) return Result.Failure(new[] { "ApplicationUser not found." }); - - applicationUser.StoredDataUrls.WebsiteIconUrl = url; - - var response = await userManager.UpdateAsync(applicationUser); - - return response.ToApplicationResult(); - } - - public async Task IsInRoleAsync(string userId, string role) - { - var user = await userManager.FindByIdAsync(userId); + var user = await userManager.FindByIdAsync(userId.ToString()); return user != null && await userManager.IsInRoleAsync(user, role); } - + public async Task CurrentUserIsInRoleAsync(string role) { var currentUserModel = await GetCurrentUserAsync(); - var currentUser = await userManager.FindByIdAsync(currentUserModel?.Id ?? ""); + var currentUser = await userManager.FindByIdAsync(currentUserModel.Id.ToString()); return currentUser != null && await userManager.IsInRoleAsync(currentUser, role); } - public async Task AuthorizeAsync(string userId, string policyName) + public async Task AuthorizeAsync(Guid userId, string policyName) { - var user = await userManager.FindByIdAsync(userId); + var user = await userManager.FindByIdAsync(userId.ToString()); if (user == null) { @@ -380,44 +224,45 @@ public class IdentityService( return result.ToApplicationResult(); } - + public async Task AddRoleAsync(string userId, string role) { var hasAdminAccess = await CurrentUserIsInRoleAsync("Administrator"); - - if (!hasAdminAccess) return Result.Failure(new []{"Only administrator can assign new roles to a user."}); + + if (!hasAdminAccess) return Result.Failure(new[] { "Only administrator can assign new roles to a user." }); var user = await userManager.FindByIdAsync(userId); - - if (user is null) return Result.Failure(new []{"User not found."}); - + + if (user is null) return Result.Failure(new[] { "User not found." }); + var result = await userManager.AddToRoleAsync(user, role); return result.ToApplicationResult(); } - + public async Task> GetCurrentUserRolesAsync() { var currentUserModel = await GetCurrentUserAsync(); - - var currentUser = await userManager.FindByIdAsync(currentUserModel?.Id ?? ""); - - if (currentUser is null) return []; + + var currentUser = await userManager.FindByIdAsync(currentUserModel.Id.ToString()); + + if (currentUser is null) return []; var userRoles = await userManager.GetRolesAsync(currentUser); return userRoles; } - + public async Task LoginAsync(string userName, string password) { - var result = await signInManager.PasswordSignInAsync(userName, password, isPersistent: false, lockoutOnFailure: false); - + var result = + await signInManager.PasswordSignInAsync(userName, password, isPersistent: false, lockoutOnFailure: false); + if (!result.Succeeded) { return null; } - + var user = await GetUserByUserNameAsync(userName); if (user is null) throw new InvalidOperationException(); @@ -427,12 +272,12 @@ public class IdentityService( issuer: jwtOptions.Value.Issuer, audience: jwtOptions.Value.Audience, key: jwtOptions.Value.Key, - userId: user.Id, + userId: user.Id.ToString(), email: user.Email, alias: user.Alias, firstname: user.FirstName, lastname: user.LastName, - profilePictureUrl: user.StoredDataUrls.ProfilePictureUrl); + portraitUrl: user.PortraitUrl); return token; } diff --git a/src/Infrastructure/Identity/OwnedEntities/ProfileColors.cs b/src/Infrastructure/Identity/OwnedEntities/ProfileColors.cs deleted file mode 100644 index 3783044..0000000 --- a/src/Infrastructure/Identity/OwnedEntities/ProfileColors.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace Hutopy.Infrastructure.Identity.OwnedEntities; - -public class ProfileColors -{ - public string BannerTop { get; init; } = string.Empty; - public string BannerBottom { get; init; } = string.Empty; - public string Accent { get; init; } = string.Empty; - public string Menu { get; init; } = string.Empty; -} diff --git a/src/Infrastructure/Identity/OwnedEntities/SocialNetworks.cs b/src/Infrastructure/Identity/OwnedEntities/SocialNetworks.cs deleted file mode 100644 index a03e139..0000000 --- a/src/Infrastructure/Identity/OwnedEntities/SocialNetworks.cs +++ /dev/null @@ -1,13 +0,0 @@ -namespace Hutopy.Infrastructure.Identity.OwnedEntities; - -public class SocialNetworks -{ - public string FacebookUrl { get; init; } = string.Empty; - public string InstagramUrl { get; init; } = string.Empty; - public string XUrl { get; init; } = string.Empty; - public string LinkedInUrl { get; init; } = string.Empty; - public string TikTokUrl { get; init; } = string.Empty; - public string YoutubeUrl { get; init; } = string.Empty; - public string RedditUrl { get; init; } = string.Empty; - public string YourWebsiteUrl { get; init; } = string.Empty; -} diff --git a/src/Infrastructure/Identity/OwnedEntities/StoredDataUrls.cs b/src/Infrastructure/Identity/OwnedEntities/StoredDataUrls.cs deleted file mode 100644 index 53d5346..0000000 --- a/src/Infrastructure/Identity/OwnedEntities/StoredDataUrls.cs +++ /dev/null @@ -1,10 +0,0 @@ -using System.ComponentModel.DataAnnotations; - -namespace Hutopy.Infrastructure.Identity.OwnedEntities; - -public class StoredDataUrls -{ - [MaxLength(255)] public string? BannerPictureUrl { get; set; } - [MaxLength(255)] public string? ProfilePictureUrl { get; set; } - [MaxLength(255)] public string? WebsiteIconUrl { get; set; } -} diff --git a/src/Infrastructure/Identity/RoleService.cs b/src/Infrastructure/Identity/RoleService.cs index 59fc22b..ef8749a 100644 --- a/src/Infrastructure/Identity/RoleService.cs +++ b/src/Infrastructure/Identity/RoleService.cs @@ -1,6 +1,4 @@ -using System; -using System.Threading.Tasks; -using Hutopy.Application.Common.Interfaces; +using Hutopy.Application.Common.Interfaces; using Hutopy.Application.Common.Models; using Microsoft.AspNetCore.Identity; @@ -13,7 +11,7 @@ public class RoleService( { public async Task CreateRoleAsync(string roleName) { - var role = new ApplicationRole { Name = roleName, Id = Guid.NewGuid().ToString()}; + var role = new ApplicationRole { Name = roleName, Id = Guid.NewGuid()}; var result = await roleManager.CreateAsync(role); return result.ToApplicationResult(); diff --git a/src/Infrastructure/Infrastructure.csproj b/src/Infrastructure/Infrastructure.csproj index 36b3844..93b2a22 100644 --- a/src/Infrastructure/Infrastructure.csproj +++ b/src/Infrastructure/Infrastructure.csproj @@ -4,21 +4,24 @@ Hutopy.Infrastructure - - - - + + + + runtime; build; native; contentfiles; analyzers; buildtransitive all - - - - - + + + + + - + + + + diff --git a/src/Infrastructure/Migrations/20240418221249_InitialMigration.Designer.cs b/src/Infrastructure/Migrations/20240418221249_InitialMigration.Designer.cs deleted file mode 100644 index e1c834e..0000000 --- a/src/Infrastructure/Migrations/20240418221249_InitialMigration.Designer.cs +++ /dev/null @@ -1,334 +0,0 @@ -// -using System; -using Hutopy.Infrastructure.Data; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -#nullable disable - -namespace Hutopy.Infrastructure.Migrations -{ - [DbContext(typeof(ApplicationDbContext))] - [Migration("20240418221249_InitialMigration")] - partial class InitialMigration - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "8.0.3") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); - - modelBuilder.Entity("Hutopy.Domain.Entities.FutureCreator", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier"); - - b.Property("Created") - .HasColumnType("datetimeoffset"); - - b.Property("CreatedBy") - .HasColumnType("nvarchar(max)"); - - b.Property("EmailAddress") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("FirstName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("LastModified") - .HasColumnType("datetimeoffset"); - - b.Property("LastModifiedBy") - .HasColumnType("nvarchar(max)"); - - b.Property("LastName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("PhoneNumber") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("ReasonToJoin") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("SocialNetworkAccount") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.ToTable("FutureCreators"); - }); - - modelBuilder.Entity("Hutopy.Infrastructure.Identity.ApplicationUser", b => - { - b.Property("Id") - .HasColumnType("nvarchar(450)"); - - b.Property("AccessFailedCount") - .HasColumnType("int"); - - b.Property("ConcurrencyStamp") - .IsConcurrencyToken() - .HasColumnType("nvarchar(max)"); - - b.Property("Email") - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.Property("EmailConfirmed") - .HasColumnType("bit"); - - b.Property("FirstName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("LastName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("LockoutEnabled") - .HasColumnType("bit"); - - b.Property("LockoutEnd") - .HasColumnType("datetimeoffset"); - - b.Property("NormalizedEmail") - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.Property("NormalizedUserName") - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.Property("PasswordHash") - .HasColumnType("nvarchar(max)"); - - b.Property("PhoneNumber") - .HasColumnType("nvarchar(max)"); - - b.Property("PhoneNumberConfirmed") - .HasColumnType("bit"); - - b.Property("SecurityStamp") - .HasColumnType("nvarchar(max)"); - - b.Property("TwoFactorEnabled") - .HasColumnType("bit"); - - b.Property("UserName") - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.HasKey("Id"); - - b.HasIndex("NormalizedEmail") - .HasDatabaseName("EmailIndex"); - - b.HasIndex("NormalizedUserName") - .IsUnique() - .HasDatabaseName("UserNameIndex") - .HasFilter("[NormalizedUserName] IS NOT NULL"); - - b.ToTable("AspNetUsers", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b => - { - b.Property("Id") - .HasColumnType("nvarchar(450)"); - - b.Property("ConcurrencyStamp") - .IsConcurrencyToken() - .HasColumnType("nvarchar(max)"); - - b.Property("Name") - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.Property("NormalizedName") - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.HasKey("Id"); - - b.HasIndex("NormalizedName") - .IsUnique() - .HasDatabaseName("RoleNameIndex") - .HasFilter("[NormalizedName] IS NOT NULL"); - - b.ToTable("AspNetRoles", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ClaimType") - .HasColumnType("nvarchar(max)"); - - b.Property("ClaimValue") - .HasColumnType("nvarchar(max)"); - - b.Property("RoleId") - .IsRequired() - .HasColumnType("nvarchar(450)"); - - b.HasKey("Id"); - - b.HasIndex("RoleId"); - - b.ToTable("AspNetRoleClaims", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ClaimType") - .HasColumnType("nvarchar(max)"); - - b.Property("ClaimValue") - .HasColumnType("nvarchar(max)"); - - b.Property("UserId") - .IsRequired() - .HasColumnType("nvarchar(450)"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("AspNetUserClaims", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => - { - b.Property("LoginProvider") - .HasColumnType("nvarchar(450)"); - - b.Property("ProviderKey") - .HasColumnType("nvarchar(450)"); - - b.Property("ProviderDisplayName") - .HasColumnType("nvarchar(max)"); - - b.Property("UserId") - .IsRequired() - .HasColumnType("nvarchar(450)"); - - b.HasKey("LoginProvider", "ProviderKey"); - - b.HasIndex("UserId"); - - b.ToTable("AspNetUserLogins", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => - { - b.Property("UserId") - .HasColumnType("nvarchar(450)"); - - b.Property("RoleId") - .HasColumnType("nvarchar(450)"); - - b.HasKey("UserId", "RoleId"); - - b.HasIndex("RoleId"); - - b.ToTable("AspNetUserRoles", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => - { - b.Property("UserId") - .HasColumnType("nvarchar(450)"); - - b.Property("LoginProvider") - .HasColumnType("nvarchar(450)"); - - b.Property("Name") - .HasColumnType("nvarchar(450)"); - - b.Property("Value") - .HasColumnType("nvarchar(max)"); - - b.HasKey("UserId", "LoginProvider", "Name"); - - b.ToTable("AspNetUserTokens", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => - { - b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) - .WithMany() - .HasForeignKey("RoleId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => - { - b.HasOne("Hutopy.Infrastructure.Identity.ApplicationUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => - { - b.HasOne("Hutopy.Infrastructure.Identity.ApplicationUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => - { - b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) - .WithMany() - .HasForeignKey("RoleId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Hutopy.Infrastructure.Identity.ApplicationUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => - { - b.HasOne("Hutopy.Infrastructure.Identity.ApplicationUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/Infrastructure/Migrations/20240422173330_AddUserTransactions.Designer.cs b/src/Infrastructure/Migrations/20240422173330_AddUserTransactions.Designer.cs deleted file mode 100644 index cc634ad..0000000 --- a/src/Infrastructure/Migrations/20240422173330_AddUserTransactions.Designer.cs +++ /dev/null @@ -1,383 +0,0 @@ -// -using System; -using Hutopy.Infrastructure.Data; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -#nullable disable - -namespace Hutopy.Infrastructure.Migrations -{ - [DbContext(typeof(ApplicationDbContext))] - [Migration("20240422173330_AddUserTransactions")] - partial class AddUserTransactions - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "8.0.3") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); - - modelBuilder.Entity("Hutopy.Domain.Entities.FutureCreator", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier"); - - b.Property("Created") - .HasColumnType("datetimeoffset"); - - b.Property("CreatedBy") - .HasColumnType("nvarchar(max)"); - - b.Property("EmailAddress") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("FirstName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("LastModified") - .HasColumnType("datetimeoffset"); - - b.Property("LastModifiedBy") - .HasColumnType("nvarchar(max)"); - - b.Property("LastName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("PhoneNumber") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("ReasonToJoin") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("SocialNetworkAccount") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.ToTable("FutureCreators"); - }); - - modelBuilder.Entity("Hutopy.Domain.Entities.UserTransaction", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier"); - - b.Property("Amount") - .HasColumnType("decimal(18,2)"); - - b.Property("ApplicationUserId") - .IsRequired() - .HasColumnType("nvarchar(450)"); - - b.Property("Created") - .HasColumnType("datetimeoffset"); - - b.Property("CreatedBy") - .HasColumnType("nvarchar(max)"); - - b.Property("Currency") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("LastModified") - .HasColumnType("datetimeoffset"); - - b.Property("LastModifiedBy") - .HasColumnType("nvarchar(max)"); - - b.Property("TipMessage") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.HasIndex("ApplicationUserId"); - - b.ToTable("UserTransactions"); - }); - - modelBuilder.Entity("Hutopy.Infrastructure.Identity.ApplicationUser", b => - { - b.Property("Id") - .HasColumnType("nvarchar(450)"); - - b.Property("AccessFailedCount") - .HasColumnType("int"); - - b.Property("ConcurrencyStamp") - .IsConcurrencyToken() - .HasColumnType("nvarchar(max)"); - - b.Property("Email") - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.Property("EmailConfirmed") - .HasColumnType("bit"); - - b.Property("FirstName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("LastName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("LockoutEnabled") - .HasColumnType("bit"); - - b.Property("LockoutEnd") - .HasColumnType("datetimeoffset"); - - b.Property("NormalizedEmail") - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.Property("NormalizedUserName") - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.Property("PasswordHash") - .HasColumnType("nvarchar(max)"); - - b.Property("PhoneNumber") - .HasColumnType("nvarchar(max)"); - - b.Property("PhoneNumberConfirmed") - .HasColumnType("bit"); - - b.Property("SecurityStamp") - .HasColumnType("nvarchar(max)"); - - b.Property("TwoFactorEnabled") - .HasColumnType("bit"); - - b.Property("UserName") - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.HasKey("Id"); - - b.HasIndex("NormalizedEmail") - .HasDatabaseName("EmailIndex"); - - b.HasIndex("NormalizedUserName") - .IsUnique() - .HasDatabaseName("UserNameIndex") - .HasFilter("[NormalizedUserName] IS NOT NULL"); - - b.ToTable("AspNetUsers", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b => - { - b.Property("Id") - .HasColumnType("nvarchar(450)"); - - b.Property("ConcurrencyStamp") - .IsConcurrencyToken() - .HasColumnType("nvarchar(max)"); - - b.Property("Name") - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.Property("NormalizedName") - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.HasKey("Id"); - - b.HasIndex("NormalizedName") - .IsUnique() - .HasDatabaseName("RoleNameIndex") - .HasFilter("[NormalizedName] IS NOT NULL"); - - b.ToTable("AspNetRoles", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ClaimType") - .HasColumnType("nvarchar(max)"); - - b.Property("ClaimValue") - .HasColumnType("nvarchar(max)"); - - b.Property("RoleId") - .IsRequired() - .HasColumnType("nvarchar(450)"); - - b.HasKey("Id"); - - b.HasIndex("RoleId"); - - b.ToTable("AspNetRoleClaims", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ClaimType") - .HasColumnType("nvarchar(max)"); - - b.Property("ClaimValue") - .HasColumnType("nvarchar(max)"); - - b.Property("UserId") - .IsRequired() - .HasColumnType("nvarchar(450)"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("AspNetUserClaims", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => - { - b.Property("LoginProvider") - .HasColumnType("nvarchar(450)"); - - b.Property("ProviderKey") - .HasColumnType("nvarchar(450)"); - - b.Property("ProviderDisplayName") - .HasColumnType("nvarchar(max)"); - - b.Property("UserId") - .IsRequired() - .HasColumnType("nvarchar(450)"); - - b.HasKey("LoginProvider", "ProviderKey"); - - b.HasIndex("UserId"); - - b.ToTable("AspNetUserLogins", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => - { - b.Property("UserId") - .HasColumnType("nvarchar(450)"); - - b.Property("RoleId") - .HasColumnType("nvarchar(450)"); - - b.HasKey("UserId", "RoleId"); - - b.HasIndex("RoleId"); - - b.ToTable("AspNetUserRoles", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => - { - b.Property("UserId") - .HasColumnType("nvarchar(450)"); - - b.Property("LoginProvider") - .HasColumnType("nvarchar(450)"); - - b.Property("Name") - .HasColumnType("nvarchar(450)"); - - b.Property("Value") - .HasColumnType("nvarchar(max)"); - - b.HasKey("UserId", "LoginProvider", "Name"); - - b.ToTable("AspNetUserTokens", (string)null); - }); - - modelBuilder.Entity("Hutopy.Domain.Entities.UserTransaction", b => - { - b.HasOne("Hutopy.Infrastructure.Identity.ApplicationUser", null) - .WithMany() - .HasForeignKey("ApplicationUserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => - { - b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) - .WithMany() - .HasForeignKey("RoleId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => - { - b.HasOne("Hutopy.Infrastructure.Identity.ApplicationUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => - { - b.HasOne("Hutopy.Infrastructure.Identity.ApplicationUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => - { - b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) - .WithMany() - .HasForeignKey("RoleId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Hutopy.Infrastructure.Identity.ApplicationUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => - { - b.HasOne("Hutopy.Infrastructure.Identity.ApplicationUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/Infrastructure/Migrations/20240422173330_AddUserTransactions.cs b/src/Infrastructure/Migrations/20240422173330_AddUserTransactions.cs deleted file mode 100644 index f60e3fc..0000000 --- a/src/Infrastructure/Migrations/20240422173330_AddUserTransactions.cs +++ /dev/null @@ -1,52 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Hutopy.Infrastructure.Migrations -{ - /// - public partial class AddUserTransactions : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "UserTransactions", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - Amount = table.Column(type: "decimal(18,2)", nullable: false), - Currency = table.Column(type: "nvarchar(max)", nullable: false), - TipMessage = table.Column(type: "nvarchar(max)", nullable: false), - ApplicationUserId = table.Column(type: "nvarchar(450)", nullable: false), - Created = table.Column(type: "datetimeoffset", nullable: false), - CreatedBy = table.Column(type: "nvarchar(max)", nullable: true), - LastModified = table.Column(type: "datetimeoffset", nullable: false), - LastModifiedBy = table.Column(type: "nvarchar(max)", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_UserTransactions", x => x.Id); - table.ForeignKey( - name: "FK_UserTransactions_AspNetUsers_ApplicationUserId", - column: x => x.ApplicationUserId, - principalTable: "AspNetUsers", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateIndex( - name: "IX_UserTransactions_ApplicationUserId", - table: "UserTransactions", - column: "ApplicationUserId"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "UserTransactions"); - } - } -} diff --git a/src/Infrastructure/Migrations/20240425020920_AddIsConfirmedToUserTransaction.Designer.cs b/src/Infrastructure/Migrations/20240425020920_AddIsConfirmedToUserTransaction.Designer.cs deleted file mode 100644 index 80ac05b..0000000 --- a/src/Infrastructure/Migrations/20240425020920_AddIsConfirmedToUserTransaction.Designer.cs +++ /dev/null @@ -1,387 +0,0 @@ -// -using System; -using Hutopy.Infrastructure.Data; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -#nullable disable - -namespace Hutopy.Infrastructure.Migrations -{ - [DbContext(typeof(ApplicationDbContext))] - [Migration("20240425020920_AddIsConfirmedToUserTransaction")] - partial class AddIsConfirmedToUserTransaction - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "8.0.3") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); - - modelBuilder.Entity("Hutopy.Domain.Entities.FutureCreator", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier"); - - b.Property("Created") - .HasColumnType("datetimeoffset"); - - b.Property("CreatedBy") - .HasColumnType("nvarchar(max)"); - - b.Property("EmailAddress") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("FirstName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("LastModified") - .HasColumnType("datetimeoffset"); - - b.Property("LastModifiedBy") - .HasColumnType("nvarchar(max)"); - - b.Property("LastName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("PhoneNumber") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("ReasonToJoin") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("SocialNetworkAccount") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.ToTable("FutureCreators"); - }); - - modelBuilder.Entity("Hutopy.Domain.Entities.UserTransaction", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier"); - - b.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b.Property("ApplicationUserId") - .IsRequired() - .HasColumnType("nvarchar(450)"); - - b.Property("Created") - .HasColumnType("datetimeoffset"); - - b.Property("CreatedBy") - .HasColumnType("nvarchar(max)"); - - b.Property("Currency") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("IsConfirmed") - .HasColumnType("bit"); - - b.Property("LastModified") - .HasColumnType("datetimeoffset"); - - b.Property("LastModifiedBy") - .HasColumnType("nvarchar(max)"); - - b.Property("TipMessage") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.HasIndex("ApplicationUserId"); - - b.ToTable("UserTransactions"); - }); - - modelBuilder.Entity("Hutopy.Infrastructure.Identity.ApplicationUser", b => - { - b.Property("Id") - .HasColumnType("nvarchar(450)"); - - b.Property("AccessFailedCount") - .HasColumnType("int"); - - b.Property("ConcurrencyStamp") - .IsConcurrencyToken() - .HasColumnType("nvarchar(max)"); - - b.Property("Email") - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.Property("EmailConfirmed") - .HasColumnType("bit"); - - b.Property("FirstName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("LastName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("LockoutEnabled") - .HasColumnType("bit"); - - b.Property("LockoutEnd") - .HasColumnType("datetimeoffset"); - - b.Property("NormalizedEmail") - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.Property("NormalizedUserName") - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.Property("PasswordHash") - .HasColumnType("nvarchar(max)"); - - b.Property("PhoneNumber") - .HasColumnType("nvarchar(max)"); - - b.Property("PhoneNumberConfirmed") - .HasColumnType("bit"); - - b.Property("SecurityStamp") - .HasColumnType("nvarchar(max)"); - - b.Property("TwoFactorEnabled") - .HasColumnType("bit"); - - b.Property("UserName") - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.HasKey("Id"); - - b.HasIndex("NormalizedEmail") - .HasDatabaseName("EmailIndex"); - - b.HasIndex("NormalizedUserName") - .IsUnique() - .HasDatabaseName("UserNameIndex") - .HasFilter("[NormalizedUserName] IS NOT NULL"); - - b.ToTable("AspNetUsers", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b => - { - b.Property("Id") - .HasColumnType("nvarchar(450)"); - - b.Property("ConcurrencyStamp") - .IsConcurrencyToken() - .HasColumnType("nvarchar(max)"); - - b.Property("Name") - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.Property("NormalizedName") - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.HasKey("Id"); - - b.HasIndex("NormalizedName") - .IsUnique() - .HasDatabaseName("RoleNameIndex") - .HasFilter("[NormalizedName] IS NOT NULL"); - - b.ToTable("AspNetRoles", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ClaimType") - .HasColumnType("nvarchar(max)"); - - b.Property("ClaimValue") - .HasColumnType("nvarchar(max)"); - - b.Property("RoleId") - .IsRequired() - .HasColumnType("nvarchar(450)"); - - b.HasKey("Id"); - - b.HasIndex("RoleId"); - - b.ToTable("AspNetRoleClaims", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ClaimType") - .HasColumnType("nvarchar(max)"); - - b.Property("ClaimValue") - .HasColumnType("nvarchar(max)"); - - b.Property("UserId") - .IsRequired() - .HasColumnType("nvarchar(450)"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("AspNetUserClaims", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => - { - b.Property("LoginProvider") - .HasColumnType("nvarchar(450)"); - - b.Property("ProviderKey") - .HasColumnType("nvarchar(450)"); - - b.Property("ProviderDisplayName") - .HasColumnType("nvarchar(max)"); - - b.Property("UserId") - .IsRequired() - .HasColumnType("nvarchar(450)"); - - b.HasKey("LoginProvider", "ProviderKey"); - - b.HasIndex("UserId"); - - b.ToTable("AspNetUserLogins", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => - { - b.Property("UserId") - .HasColumnType("nvarchar(450)"); - - b.Property("RoleId") - .HasColumnType("nvarchar(450)"); - - b.HasKey("UserId", "RoleId"); - - b.HasIndex("RoleId"); - - b.ToTable("AspNetUserRoles", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => - { - b.Property("UserId") - .HasColumnType("nvarchar(450)"); - - b.Property("LoginProvider") - .HasColumnType("nvarchar(450)"); - - b.Property("Name") - .HasColumnType("nvarchar(450)"); - - b.Property("Value") - .HasColumnType("nvarchar(max)"); - - b.HasKey("UserId", "LoginProvider", "Name"); - - b.ToTable("AspNetUserTokens", (string)null); - }); - - modelBuilder.Entity("Hutopy.Domain.Entities.UserTransaction", b => - { - b.HasOne("Hutopy.Infrastructure.Identity.ApplicationUser", null) - .WithMany() - .HasForeignKey("ApplicationUserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => - { - b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) - .WithMany() - .HasForeignKey("RoleId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => - { - b.HasOne("Hutopy.Infrastructure.Identity.ApplicationUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => - { - b.HasOne("Hutopy.Infrastructure.Identity.ApplicationUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => - { - b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) - .WithMany() - .HasForeignKey("RoleId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Hutopy.Infrastructure.Identity.ApplicationUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => - { - b.HasOne("Hutopy.Infrastructure.Identity.ApplicationUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/Infrastructure/Migrations/20240425020920_AddIsConfirmedToUserTransaction.cs b/src/Infrastructure/Migrations/20240425020920_AddIsConfirmedToUserTransaction.cs deleted file mode 100644 index 39ded1c..0000000 --- a/src/Infrastructure/Migrations/20240425020920_AddIsConfirmedToUserTransaction.cs +++ /dev/null @@ -1,29 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Hutopy.Infrastructure.Migrations -{ - /// - public partial class AddIsConfirmedToUserTransaction : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "IsConfirmed", - table: "UserTransactions", - type: "bit", - nullable: false, - defaultValue: false); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "IsConfirmed", - table: "UserTransactions"); - } - } -} diff --git a/src/Infrastructure/Migrations/20240509215538_AddMoreInformationToTransaction.cs b/src/Infrastructure/Migrations/20240509215538_AddMoreInformationToTransaction.cs deleted file mode 100644 index d91d3cf..0000000 --- a/src/Infrastructure/Migrations/20240509215538_AddMoreInformationToTransaction.cs +++ /dev/null @@ -1,106 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Hutopy.Infrastructure.Migrations -{ - /// - public partial class AddMoreInformationToTransaction : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "Paid", - table: "UserTransactions", - type: "bit", - nullable: false, - defaultValue: false); - - migrationBuilder.AddColumn( - name: "StripeBillingDetailEmail", - table: "UserTransactions", - type: "nvarchar(max)", - nullable: false, - defaultValue: ""); - - migrationBuilder.AddColumn( - name: "StripeBillingDetailName", - table: "UserTransactions", - type: "nvarchar(max)", - nullable: false, - defaultValue: ""); - - migrationBuilder.AddColumn( - name: "StripeChargeId", - table: "UserTransactions", - type: "nvarchar(max)", - nullable: false, - defaultValue: ""); - - migrationBuilder.AddColumn( - name: "StripeEventId", - table: "UserTransactions", - type: "nvarchar(max)", - nullable: false, - defaultValue: ""); - - migrationBuilder.AddColumn( - name: "StripePaymentIntent", - table: "UserTransactions", - type: "nvarchar(max)", - nullable: false, - defaultValue: ""); - - migrationBuilder.AddColumn( - name: "StripePaymentMethod", - table: "UserTransactions", - type: "nvarchar(max)", - nullable: false, - defaultValue: ""); - - migrationBuilder.AddColumn( - name: "StripeReceiptUrl", - table: "UserTransactions", - type: "nvarchar(max)", - nullable: false, - defaultValue: ""); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "Paid", - table: "UserTransactions"); - - migrationBuilder.DropColumn( - name: "StripeBillingDetailEmail", - table: "UserTransactions"); - - migrationBuilder.DropColumn( - name: "StripeBillingDetailName", - table: "UserTransactions"); - - migrationBuilder.DropColumn( - name: "StripeChargeId", - table: "UserTransactions"); - - migrationBuilder.DropColumn( - name: "StripeEventId", - table: "UserTransactions"); - - migrationBuilder.DropColumn( - name: "StripePaymentIntent", - table: "UserTransactions"); - - migrationBuilder.DropColumn( - name: "StripePaymentMethod", - table: "UserTransactions"); - - migrationBuilder.DropColumn( - name: "StripeReceiptUrl", - table: "UserTransactions"); - } - } -} diff --git a/src/Infrastructure/Migrations/20240612000806_AddSocialNetworksToUser.Designer.cs b/src/Infrastructure/Migrations/20240612000806_AddSocialNetworksToUser.Designer.cs deleted file mode 100644 index 2c074bc..0000000 --- a/src/Infrastructure/Migrations/20240612000806_AddSocialNetworksToUser.Designer.cs +++ /dev/null @@ -1,469 +0,0 @@ -// -using System; -using Hutopy.Infrastructure.Data; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -#nullable disable - -namespace Hutopy.Infrastructure.Migrations -{ - [DbContext(typeof(ApplicationDbContext))] - [Migration("20240612000806_AddSocialNetworksToUser")] - partial class AddSocialNetworksToUser - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "8.0.3") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); - - modelBuilder.Entity("Hutopy.Domain.Entities.FutureCreator", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier"); - - b.Property("Created") - .HasColumnType("datetimeoffset"); - - b.Property("CreatedBy") - .HasColumnType("nvarchar(max)"); - - b.Property("EmailAddress") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("FirstName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("LastModified") - .HasColumnType("datetimeoffset"); - - b.Property("LastModifiedBy") - .HasColumnType("nvarchar(max)"); - - b.Property("LastName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("PhoneNumber") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("ReasonToJoin") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("SocialNetworkAccount") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.ToTable("FutureCreators"); - }); - - modelBuilder.Entity("Hutopy.Domain.Entities.UserTransaction", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier"); - - b.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b.Property("ApplicationUserId") - .IsRequired() - .HasColumnType("nvarchar(450)"); - - b.Property("Created") - .HasColumnType("datetimeoffset"); - - b.Property("CreatedBy") - .HasColumnType("nvarchar(max)"); - - b.Property("Currency") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("IsConfirmed") - .HasColumnType("bit"); - - b.Property("LastModified") - .HasColumnType("datetimeoffset"); - - b.Property("LastModifiedBy") - .HasColumnType("nvarchar(max)"); - - b.Property("Paid") - .HasColumnType("bit"); - - b.Property("StripeBillingDetailEmail") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("StripeBillingDetailName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("StripeChargeId") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("StripeEventId") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("StripePaymentIntent") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("StripePaymentMethod") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("StripeReceiptUrl") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("TipMessage") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.HasIndex("ApplicationUserId"); - - b.ToTable("UserTransactions"); - }); - - modelBuilder.Entity("Hutopy.Infrastructure.Identity.ApplicationUser", b => - { - b.Property("Id") - .HasColumnType("nvarchar(450)"); - - b.Property("AccessFailedCount") - .HasColumnType("int"); - - b.Property("ConcurrencyStamp") - .IsConcurrencyToken() - .HasColumnType("nvarchar(max)"); - - b.Property("Email") - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.Property("EmailConfirmed") - .HasColumnType("bit"); - - b.Property("FirstName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("LastName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("LockoutEnabled") - .HasColumnType("bit"); - - b.Property("LockoutEnd") - .HasColumnType("datetimeoffset"); - - b.Property("NormalizedEmail") - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.Property("NormalizedUserName") - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.Property("PasswordHash") - .HasColumnType("nvarchar(max)"); - - b.Property("PhoneNumber") - .HasColumnType("nvarchar(max)"); - - b.Property("PhoneNumberConfirmed") - .HasColumnType("bit"); - - b.Property("SecurityStamp") - .HasColumnType("nvarchar(max)"); - - b.Property("TwoFactorEnabled") - .HasColumnType("bit"); - - b.Property("UserName") - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.HasKey("Id"); - - b.HasIndex("NormalizedEmail") - .HasDatabaseName("EmailIndex"); - - b.HasIndex("NormalizedUserName") - .IsUnique() - .HasDatabaseName("UserNameIndex") - .HasFilter("[NormalizedUserName] IS NOT NULL"); - - b.ToTable("AspNetUsers", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b => - { - b.Property("Id") - .HasColumnType("nvarchar(450)"); - - b.Property("ConcurrencyStamp") - .IsConcurrencyToken() - .HasColumnType("nvarchar(max)"); - - b.Property("Name") - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.Property("NormalizedName") - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.HasKey("Id"); - - b.HasIndex("NormalizedName") - .IsUnique() - .HasDatabaseName("RoleNameIndex") - .HasFilter("[NormalizedName] IS NOT NULL"); - - b.ToTable("AspNetRoles", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ClaimType") - .HasColumnType("nvarchar(max)"); - - b.Property("ClaimValue") - .HasColumnType("nvarchar(max)"); - - b.Property("RoleId") - .IsRequired() - .HasColumnType("nvarchar(450)"); - - b.HasKey("Id"); - - b.HasIndex("RoleId"); - - b.ToTable("AspNetRoleClaims", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ClaimType") - .HasColumnType("nvarchar(max)"); - - b.Property("ClaimValue") - .HasColumnType("nvarchar(max)"); - - b.Property("UserId") - .IsRequired() - .HasColumnType("nvarchar(450)"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("AspNetUserClaims", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => - { - b.Property("LoginProvider") - .HasColumnType("nvarchar(450)"); - - b.Property("ProviderKey") - .HasColumnType("nvarchar(450)"); - - b.Property("ProviderDisplayName") - .HasColumnType("nvarchar(max)"); - - b.Property("UserId") - .IsRequired() - .HasColumnType("nvarchar(450)"); - - b.HasKey("LoginProvider", "ProviderKey"); - - b.HasIndex("UserId"); - - b.ToTable("AspNetUserLogins", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => - { - b.Property("UserId") - .HasColumnType("nvarchar(450)"); - - b.Property("RoleId") - .HasColumnType("nvarchar(450)"); - - b.HasKey("UserId", "RoleId"); - - b.HasIndex("RoleId"); - - b.ToTable("AspNetUserRoles", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => - { - b.Property("UserId") - .HasColumnType("nvarchar(450)"); - - b.Property("LoginProvider") - .HasColumnType("nvarchar(450)"); - - b.Property("Name") - .HasColumnType("nvarchar(450)"); - - b.Property("Value") - .HasColumnType("nvarchar(max)"); - - b.HasKey("UserId", "LoginProvider", "Name"); - - b.ToTable("AspNetUserTokens", (string)null); - }); - - modelBuilder.Entity("Hutopy.Domain.Entities.UserTransaction", b => - { - b.HasOne("Hutopy.Infrastructure.Identity.ApplicationUser", null) - .WithMany() - .HasForeignKey("ApplicationUserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Hutopy.Infrastructure.Identity.ApplicationUser", b => - { - b.OwnsOne("Hutopy.Infrastructure.Identity.OwnedEntities.SocialNetworks", "SocialNetworks", b1 => - { - b1.Property("ApplicationUserId") - .HasColumnType("nvarchar(450)"); - - b1.Property("FacebookUrl") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("InstagramUrl") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("LinkedInUrl") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("RedditUrl") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("TikTokUrl") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("XUrl") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("YourWebsiteUrl") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("YoutubeUrl") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.HasKey("ApplicationUserId"); - - b1.ToTable("ApplicationUser_SocialNetworks", (string)null); - - b1.WithOwner() - .HasForeignKey("ApplicationUserId"); - }); - - b.Navigation("SocialNetworks") - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => - { - b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) - .WithMany() - .HasForeignKey("RoleId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => - { - b.HasOne("Hutopy.Infrastructure.Identity.ApplicationUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => - { - b.HasOne("Hutopy.Infrastructure.Identity.ApplicationUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => - { - b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) - .WithMany() - .HasForeignKey("RoleId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Hutopy.Infrastructure.Identity.ApplicationUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => - { - b.HasOne("Hutopy.Infrastructure.Identity.ApplicationUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/Infrastructure/Migrations/20240612000806_AddSocialNetworksToUser.cs b/src/Infrastructure/Migrations/20240612000806_AddSocialNetworksToUser.cs deleted file mode 100644 index 14dfa81..0000000 --- a/src/Infrastructure/Migrations/20240612000806_AddSocialNetworksToUser.cs +++ /dev/null @@ -1,52 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Hutopy.Infrastructure.Migrations -{ - /// - public partial class AddSocialNetworksToUser : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "ApplicationUser_SocialNetworks", - columns: table => new - { - ApplicationUserId = table.Column(type: "nvarchar(450)", nullable: false), - FacebookUrl = table.Column(type: "nvarchar(max)", nullable: false), - InstagramUrl = table.Column(type: "nvarchar(max)", nullable: false), - XUrl = table.Column(type: "nvarchar(max)", nullable: false), - LinkedInUrl = table.Column(type: "nvarchar(max)", nullable: false), - TikTokUrl = table.Column(type: "nvarchar(max)", nullable: false), - YoutubeUrl = table.Column(type: "nvarchar(max)", nullable: false), - RedditUrl = table.Column(type: "nvarchar(max)", nullable: false), - YourWebsiteUrl = table.Column(type: "nvarchar(max)", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_ApplicationUser_SocialNetworks", x => x.ApplicationUserId); - table.ForeignKey( - name: "FK_ApplicationUser_SocialNetworks_AspNetUsers_ApplicationUserId", - column: x => x.ApplicationUserId, - principalTable: "AspNetUsers", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.Sql(@" - INSERT INTO ApplicationUser_SocialNetworks (ApplicationUserId, FacebookUrl, InstagramUrl, XUrl, LinkedInUrl, TikTokUrl, YoutubeUrl, RedditUrl, YourWebsiteUrl) - SELECT Id, '', '', '', '', '', '', '', '' - FROM AspNetUsers - "); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "ApplicationUser_SocialNetworks"); - } - } -} diff --git a/src/Infrastructure/Migrations/20240630001806_AddMissingInformationsToUser.Designer.cs b/src/Infrastructure/Migrations/20240630001806_AddMissingInformationsToUser.Designer.cs deleted file mode 100644 index 2a9623e..0000000 --- a/src/Infrastructure/Migrations/20240630001806_AddMissingInformationsToUser.Designer.cs +++ /dev/null @@ -1,497 +0,0 @@ -// -using System; -using Hutopy.Infrastructure.Data; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -#nullable disable - -namespace Hutopy.Infrastructure.Migrations -{ - [DbContext(typeof(ApplicationDbContext))] - [Migration("20240630001806_AddMissingInformationsToUser")] - partial class AddMissingInformationsToUser - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "8.0.3") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); - - modelBuilder.Entity("Hutopy.Domain.Entities.FutureCreator", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier"); - - b.Property("Created") - .HasColumnType("datetimeoffset"); - - b.Property("CreatedBy") - .HasColumnType("nvarchar(max)"); - - b.Property("EmailAddress") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("FirstName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("LastModified") - .HasColumnType("datetimeoffset"); - - b.Property("LastModifiedBy") - .HasColumnType("nvarchar(max)"); - - b.Property("LastName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("PhoneNumber") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("ReasonToJoin") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("SocialNetworkAccount") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.ToTable("FutureCreators"); - }); - - modelBuilder.Entity("Hutopy.Domain.Entities.UserTransaction", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier"); - - b.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b.Property("ApplicationUserId") - .IsRequired() - .HasColumnType("nvarchar(450)"); - - b.Property("Created") - .HasColumnType("datetimeoffset"); - - b.Property("CreatedBy") - .HasColumnType("nvarchar(max)"); - - b.Property("Currency") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("IsConfirmed") - .HasColumnType("bit"); - - b.Property("LastModified") - .HasColumnType("datetimeoffset"); - - b.Property("LastModifiedBy") - .HasColumnType("nvarchar(max)"); - - b.Property("Paid") - .HasColumnType("bit"); - - b.Property("StripeBillingDetailEmail") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("StripeBillingDetailName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("StripeChargeId") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("StripeEventId") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("StripePaymentIntent") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("StripePaymentMethod") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("StripeReceiptUrl") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("TipMessage") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.HasIndex("ApplicationUserId"); - - b.ToTable("UserTransactions"); - }); - - modelBuilder.Entity("Hutopy.Infrastructure.Identity.ApplicationUser", b => - { - b.Property("Id") - .HasColumnType("nvarchar(450)"); - - b.Property("About") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("AccessFailedCount") - .HasColumnType("int"); - - b.Property("Address") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("BirthDate") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("City") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("ConcurrencyStamp") - .IsConcurrencyToken() - .HasColumnType("nvarchar(max)"); - - b.Property("Country") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Description") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Email") - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.Property("EmailConfirmed") - .HasColumnType("bit"); - - b.Property("FirstName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("LastName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("LockoutEnabled") - .HasColumnType("bit"); - - b.Property("LockoutEnd") - .HasColumnType("datetimeoffset"); - - b.Property("NormalizedEmail") - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.Property("NormalizedUserName") - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.Property("Occupation") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("PasswordHash") - .HasColumnType("nvarchar(max)"); - - b.Property("PhoneNumber") - .HasColumnType("nvarchar(max)"); - - b.Property("PhoneNumberConfirmed") - .HasColumnType("bit"); - - b.Property("SecurityStamp") - .HasColumnType("nvarchar(max)"); - - b.Property("TwoFactorEnabled") - .HasColumnType("bit"); - - b.Property("UserName") - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.HasKey("Id"); - - b.HasIndex("NormalizedEmail") - .HasDatabaseName("EmailIndex"); - - b.HasIndex("NormalizedUserName") - .IsUnique() - .HasDatabaseName("UserNameIndex") - .HasFilter("[NormalizedUserName] IS NOT NULL"); - - b.ToTable("AspNetUsers", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b => - { - b.Property("Id") - .HasColumnType("nvarchar(450)"); - - b.Property("ConcurrencyStamp") - .IsConcurrencyToken() - .HasColumnType("nvarchar(max)"); - - b.Property("Name") - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.Property("NormalizedName") - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.HasKey("Id"); - - b.HasIndex("NormalizedName") - .IsUnique() - .HasDatabaseName("RoleNameIndex") - .HasFilter("[NormalizedName] IS NOT NULL"); - - b.ToTable("AspNetRoles", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ClaimType") - .HasColumnType("nvarchar(max)"); - - b.Property("ClaimValue") - .HasColumnType("nvarchar(max)"); - - b.Property("RoleId") - .IsRequired() - .HasColumnType("nvarchar(450)"); - - b.HasKey("Id"); - - b.HasIndex("RoleId"); - - b.ToTable("AspNetRoleClaims", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ClaimType") - .HasColumnType("nvarchar(max)"); - - b.Property("ClaimValue") - .HasColumnType("nvarchar(max)"); - - b.Property("UserId") - .IsRequired() - .HasColumnType("nvarchar(450)"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("AspNetUserClaims", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => - { - b.Property("LoginProvider") - .HasColumnType("nvarchar(450)"); - - b.Property("ProviderKey") - .HasColumnType("nvarchar(450)"); - - b.Property("ProviderDisplayName") - .HasColumnType("nvarchar(max)"); - - b.Property("UserId") - .IsRequired() - .HasColumnType("nvarchar(450)"); - - b.HasKey("LoginProvider", "ProviderKey"); - - b.HasIndex("UserId"); - - b.ToTable("AspNetUserLogins", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => - { - b.Property("UserId") - .HasColumnType("nvarchar(450)"); - - b.Property("RoleId") - .HasColumnType("nvarchar(450)"); - - b.HasKey("UserId", "RoleId"); - - b.HasIndex("RoleId"); - - b.ToTable("AspNetUserRoles", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => - { - b.Property("UserId") - .HasColumnType("nvarchar(450)"); - - b.Property("LoginProvider") - .HasColumnType("nvarchar(450)"); - - b.Property("Name") - .HasColumnType("nvarchar(450)"); - - b.Property("Value") - .HasColumnType("nvarchar(max)"); - - b.HasKey("UserId", "LoginProvider", "Name"); - - b.ToTable("AspNetUserTokens", (string)null); - }); - - modelBuilder.Entity("Hutopy.Domain.Entities.UserTransaction", b => - { - b.HasOne("Hutopy.Infrastructure.Identity.ApplicationUser", null) - .WithMany() - .HasForeignKey("ApplicationUserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Hutopy.Infrastructure.Identity.ApplicationUser", b => - { - b.OwnsOne("Hutopy.Infrastructure.Identity.OwnedEntities.SocialNetworks", "SocialNetworks", b1 => - { - b1.Property("ApplicationUserId") - .HasColumnType("nvarchar(450)"); - - b1.Property("FacebookUrl") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("InstagramUrl") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("LinkedInUrl") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("RedditUrl") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("TikTokUrl") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("XUrl") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("YourWebsiteUrl") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("YoutubeUrl") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.HasKey("ApplicationUserId"); - - b1.ToTable("ApplicationUser_SocialNetworks", (string)null); - - b1.WithOwner() - .HasForeignKey("ApplicationUserId"); - }); - - b.Navigation("SocialNetworks") - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => - { - b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) - .WithMany() - .HasForeignKey("RoleId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => - { - b.HasOne("Hutopy.Infrastructure.Identity.ApplicationUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => - { - b.HasOne("Hutopy.Infrastructure.Identity.ApplicationUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => - { - b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) - .WithMany() - .HasForeignKey("RoleId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Hutopy.Infrastructure.Identity.ApplicationUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => - { - b.HasOne("Hutopy.Infrastructure.Identity.ApplicationUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/Infrastructure/Migrations/20240630001806_AddMissingInformationsToUser.cs b/src/Infrastructure/Migrations/20240630001806_AddMissingInformationsToUser.cs deleted file mode 100644 index cd1a612..0000000 --- a/src/Infrastructure/Migrations/20240630001806_AddMissingInformationsToUser.cs +++ /dev/null @@ -1,95 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Hutopy.Infrastructure.Migrations -{ - /// - public partial class AddMissingInformationsToUser : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "About", - table: "AspNetUsers", - type: "nvarchar(max)", - nullable: false, - defaultValue: ""); - - migrationBuilder.AddColumn( - name: "Address", - table: "AspNetUsers", - type: "nvarchar(max)", - nullable: false, - defaultValue: ""); - - migrationBuilder.AddColumn( - name: "BirthDate", - table: "AspNetUsers", - type: "nvarchar(max)", - nullable: false, - defaultValue: ""); - - migrationBuilder.AddColumn( - name: "City", - table: "AspNetUsers", - type: "nvarchar(max)", - nullable: false, - defaultValue: ""); - - migrationBuilder.AddColumn( - name: "Country", - table: "AspNetUsers", - type: "nvarchar(max)", - nullable: false, - defaultValue: ""); - - migrationBuilder.AddColumn( - name: "Description", - table: "AspNetUsers", - type: "nvarchar(max)", - nullable: false, - defaultValue: ""); - - migrationBuilder.AddColumn( - name: "Occupation", - table: "AspNetUsers", - type: "nvarchar(max)", - nullable: false, - defaultValue: ""); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "About", - table: "AspNetUsers"); - - migrationBuilder.DropColumn( - name: "Address", - table: "AspNetUsers"); - - migrationBuilder.DropColumn( - name: "BirthDate", - table: "AspNetUsers"); - - migrationBuilder.DropColumn( - name: "City", - table: "AspNetUsers"); - - migrationBuilder.DropColumn( - name: "Country", - table: "AspNetUsers"); - - migrationBuilder.DropColumn( - name: "Description", - table: "AspNetUsers"); - - migrationBuilder.DropColumn( - name: "Occupation", - table: "AspNetUsers"); - } - } -} diff --git a/src/Infrastructure/Migrations/20240630163057_AddMoreInformationsToUser.Designer.cs b/src/Infrastructure/Migrations/20240630163057_AddMoreInformationsToUser.Designer.cs deleted file mode 100644 index af10f04..0000000 --- a/src/Infrastructure/Migrations/20240630163057_AddMoreInformationsToUser.Designer.cs +++ /dev/null @@ -1,557 +0,0 @@ -// -using System; -using Hutopy.Infrastructure.Data; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -#nullable disable - -namespace Hutopy.Infrastructure.Migrations -{ - [DbContext(typeof(ApplicationDbContext))] - [Migration("20240630163057_AddMoreInformationsToUser")] - partial class AddMoreInformationsToUser - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "8.0.3") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); - - modelBuilder.Entity("Hutopy.Domain.Entities.FutureCreator", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier"); - - b.Property("Created") - .HasColumnType("datetimeoffset"); - - b.Property("CreatedBy") - .HasColumnType("nvarchar(max)"); - - b.Property("EmailAddress") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("FirstName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("LastModified") - .HasColumnType("datetimeoffset"); - - b.Property("LastModifiedBy") - .HasColumnType("nvarchar(max)"); - - b.Property("LastName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("PhoneNumber") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("ReasonToJoin") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("SocialNetworkAccount") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.ToTable("FutureCreators"); - }); - - modelBuilder.Entity("Hutopy.Domain.Entities.UserTransaction", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier"); - - b.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b.Property("ApplicationUserId") - .IsRequired() - .HasColumnType("nvarchar(450)"); - - b.Property("Created") - .HasColumnType("datetimeoffset"); - - b.Property("CreatedBy") - .HasColumnType("nvarchar(max)"); - - b.Property("Currency") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("IsConfirmed") - .HasColumnType("bit"); - - b.Property("LastModified") - .HasColumnType("datetimeoffset"); - - b.Property("LastModifiedBy") - .HasColumnType("nvarchar(max)"); - - b.Property("Paid") - .HasColumnType("bit"); - - b.Property("StripeBillingDetailEmail") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("StripeBillingDetailName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("StripeChargeId") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("StripeEventId") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("StripePaymentIntent") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("StripePaymentMethod") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("StripeReceiptUrl") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("TipMessage") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.HasIndex("ApplicationUserId"); - - b.ToTable("UserTransactions"); - }); - - modelBuilder.Entity("Hutopy.Infrastructure.Identity.ApplicationUser", b => - { - b.Property("Id") - .HasColumnType("nvarchar(450)"); - - b.Property("About") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("AccessFailedCount") - .HasColumnType("int"); - - b.Property("Address") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("BirthDate") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("City") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("ConcurrencyStamp") - .IsConcurrencyToken() - .HasColumnType("nvarchar(max)"); - - b.Property("Country") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Description") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Email") - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.Property("EmailConfirmed") - .HasColumnType("bit"); - - b.Property("FirstName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("LastName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("LockoutEnabled") - .HasColumnType("bit"); - - b.Property("LockoutEnd") - .HasColumnType("datetimeoffset"); - - b.Property("NormalizedEmail") - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.Property("NormalizedUserName") - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.Property("Occupation") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("PasswordHash") - .HasColumnType("nvarchar(max)"); - - b.Property("PhoneNumber") - .HasColumnType("nvarchar(max)"); - - b.Property("PhoneNumberConfirmed") - .HasColumnType("bit"); - - b.Property("SecurityStamp") - .HasColumnType("nvarchar(max)"); - - b.Property("TwoFactorEnabled") - .HasColumnType("bit"); - - b.Property("UserName") - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.HasKey("Id"); - - b.HasIndex("NormalizedEmail") - .HasDatabaseName("EmailIndex"); - - b.HasIndex("NormalizedUserName") - .IsUnique() - .HasDatabaseName("UserNameIndex") - .HasFilter("[NormalizedUserName] IS NOT NULL"); - - b.ToTable("AspNetUsers", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b => - { - b.Property("Id") - .HasColumnType("nvarchar(450)"); - - b.Property("ConcurrencyStamp") - .IsConcurrencyToken() - .HasColumnType("nvarchar(max)"); - - b.Property("Name") - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.Property("NormalizedName") - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.HasKey("Id"); - - b.HasIndex("NormalizedName") - .IsUnique() - .HasDatabaseName("RoleNameIndex") - .HasFilter("[NormalizedName] IS NOT NULL"); - - b.ToTable("AspNetRoles", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ClaimType") - .HasColumnType("nvarchar(max)"); - - b.Property("ClaimValue") - .HasColumnType("nvarchar(max)"); - - b.Property("RoleId") - .IsRequired() - .HasColumnType("nvarchar(450)"); - - b.HasKey("Id"); - - b.HasIndex("RoleId"); - - b.ToTable("AspNetRoleClaims", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ClaimType") - .HasColumnType("nvarchar(max)"); - - b.Property("ClaimValue") - .HasColumnType("nvarchar(max)"); - - b.Property("UserId") - .IsRequired() - .HasColumnType("nvarchar(450)"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("AspNetUserClaims", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => - { - b.Property("LoginProvider") - .HasColumnType("nvarchar(450)"); - - b.Property("ProviderKey") - .HasColumnType("nvarchar(450)"); - - b.Property("ProviderDisplayName") - .HasColumnType("nvarchar(max)"); - - b.Property("UserId") - .IsRequired() - .HasColumnType("nvarchar(450)"); - - b.HasKey("LoginProvider", "ProviderKey"); - - b.HasIndex("UserId"); - - b.ToTable("AspNetUserLogins", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => - { - b.Property("UserId") - .HasColumnType("nvarchar(450)"); - - b.Property("RoleId") - .HasColumnType("nvarchar(450)"); - - b.HasKey("UserId", "RoleId"); - - b.HasIndex("RoleId"); - - b.ToTable("AspNetUserRoles", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => - { - b.Property("UserId") - .HasColumnType("nvarchar(450)"); - - b.Property("LoginProvider") - .HasColumnType("nvarchar(450)"); - - b.Property("Name") - .HasColumnType("nvarchar(450)"); - - b.Property("Value") - .HasColumnType("nvarchar(max)"); - - b.HasKey("UserId", "LoginProvider", "Name"); - - b.ToTable("AspNetUserTokens", (string)null); - }); - - modelBuilder.Entity("Hutopy.Domain.Entities.UserTransaction", b => - { - b.HasOne("Hutopy.Infrastructure.Identity.ApplicationUser", null) - .WithMany() - .HasForeignKey("ApplicationUserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Hutopy.Infrastructure.Identity.ApplicationUser", b => - { - b.OwnsOne("Hutopy.Infrastructure.Identity.OwnedEntities.ProfileColors", "ProfileColors", b1 => - { - b1.Property("ApplicationUserId") - .HasColumnType("nvarchar(450)"); - - b1.Property("Accent") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("BannerBottom") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("BannerTop") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("Menu") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.HasKey("ApplicationUserId"); - - b1.ToTable("ApplicationUser_ProfileColors", (string)null); - - b1.WithOwner() - .HasForeignKey("ApplicationUserId"); - }); - - b.OwnsOne("Hutopy.Infrastructure.Identity.OwnedEntities.SocialNetworks", "SocialNetworks", b1 => - { - b1.Property("ApplicationUserId") - .HasColumnType("nvarchar(450)"); - - b1.Property("FacebookUrl") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("InstagramUrl") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("LinkedInUrl") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("RedditUrl") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("TikTokUrl") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("XUrl") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("YourWebsiteUrl") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("YoutubeUrl") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.HasKey("ApplicationUserId"); - - b1.ToTable("ApplicationUser_SocialNetworks", (string)null); - - b1.WithOwner() - .HasForeignKey("ApplicationUserId"); - }); - - b.OwnsOne("Hutopy.Infrastructure.Identity.OwnedEntities.StoredDataUrls", "StoredDataUrls", b1 => - { - b1.Property("ApplicationUserId") - .HasColumnType("nvarchar(450)"); - - b1.Property("BannerPictureUrl") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("ProfilePictureUrl") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("WebsiteIconUrl") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.HasKey("ApplicationUserId"); - - b1.ToTable("ApplicationUser_StoredDataUrls", (string)null); - - b1.WithOwner() - .HasForeignKey("ApplicationUserId"); - }); - - b.Navigation("ProfileColors") - .IsRequired(); - - b.Navigation("SocialNetworks") - .IsRequired(); - - b.Navigation("StoredDataUrls") - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => - { - b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) - .WithMany() - .HasForeignKey("RoleId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => - { - b.HasOne("Hutopy.Infrastructure.Identity.ApplicationUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => - { - b.HasOne("Hutopy.Infrastructure.Identity.ApplicationUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => - { - b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) - .WithMany() - .HasForeignKey("RoleId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Hutopy.Infrastructure.Identity.ApplicationUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => - { - b.HasOne("Hutopy.Infrastructure.Identity.ApplicationUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/Infrastructure/Migrations/20240630163057_AddMoreInformationsToUser.cs b/src/Infrastructure/Migrations/20240630163057_AddMoreInformationsToUser.cs deleted file mode 100644 index 85e7b7e..0000000 --- a/src/Infrastructure/Migrations/20240630163057_AddMoreInformationsToUser.cs +++ /dev/null @@ -1,77 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Hutopy.Infrastructure.Migrations -{ - /// - public partial class AddMoreInformationsToUser : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "ApplicationUser_ProfileColors", - columns: table => new - { - ApplicationUserId = table.Column(type: "nvarchar(450)", nullable: false), - BannerTop = table.Column(type: "nvarchar(max)", nullable: false), - BannerBottom = table.Column(type: "nvarchar(max)", nullable: false), - Accent = table.Column(type: "nvarchar(max)", nullable: false), - Menu = table.Column(type: "nvarchar(max)", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_ApplicationUser_ProfileColors", x => x.ApplicationUserId); - table.ForeignKey( - name: "FK_ApplicationUser_ProfileColors_AspNetUsers_ApplicationUserId", - column: x => x.ApplicationUserId, - principalTable: "AspNetUsers", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.Sql(@" - INSERT INTO ApplicationUser_ProfileColors (ApplicationUserId, BannerTop, BannerBottom, Accent, Menu) - SELECT Id, '', '', '', '' - FROM AspNetUsers - "); - - migrationBuilder.CreateTable( - name: "ApplicationUser_StoredDataUrls", - columns: table => new - { - ApplicationUserId = table.Column(type: "nvarchar(450)", nullable: false), - BannerPictureUrl = table.Column(type: "nvarchar(max)", nullable: false), - ProfilePictureUrl = table.Column(type: "nvarchar(max)", nullable: false), - WebsiteIconUrl = table.Column(type: "nvarchar(max)", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_ApplicationUser_StoredDataUrls", x => x.ApplicationUserId); - table.ForeignKey( - name: "FK_ApplicationUser_StoredDataUrls_AspNetUsers_ApplicationUserId", - column: x => x.ApplicationUserId, - principalTable: "AspNetUsers", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.Sql(@" - INSERT INTO ApplicationUser_StoredDataUrls (ApplicationUserId, BannerPictureUrl, ProfilePictureUrl, WebsiteIconUrl) - SELECT Id, '', '', '' - FROM AspNetUsers - "); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "ApplicationUser_ProfileColors"); - - migrationBuilder.DropTable( - name: "ApplicationUser_StoredDataUrls"); - } - } -} diff --git a/src/Infrastructure/Migrations/20240701072549_AddPortraitUrlToUser.Designer.cs b/src/Infrastructure/Migrations/20240701072549_AddPortraitUrlToUser.Designer.cs deleted file mode 100644 index 2ce61d4..0000000 --- a/src/Infrastructure/Migrations/20240701072549_AddPortraitUrlToUser.Designer.cs +++ /dev/null @@ -1,500 +0,0 @@ -// -using System; -using Hutopy.Infrastructure.Data; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -#nullable disable - -namespace Hutopy.Infrastructure.Migrations -{ - [DbContext(typeof(ApplicationDbContext))] - [Migration("20240701072549_AddPortraitUrlToUser")] - partial class AddPortraitUrlToUser - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "8.0.3") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); - - modelBuilder.Entity("Hutopy.Domain.Entities.FutureCreator", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier"); - - b.Property("Created") - .HasColumnType("datetimeoffset"); - - b.Property("CreatedBy") - .HasColumnType("nvarchar(max)"); - - b.Property("EmailAddress") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("FirstName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("LastModified") - .HasColumnType("datetimeoffset"); - - b.Property("LastModifiedBy") - .HasColumnType("nvarchar(max)"); - - b.Property("LastName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("PhoneNumber") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("ReasonToJoin") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("SocialNetworkAccount") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.ToTable("FutureCreators"); - }); - - modelBuilder.Entity("Hutopy.Domain.Entities.UserTransaction", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier"); - - b.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b.Property("ApplicationUserId") - .IsRequired() - .HasColumnType("nvarchar(450)"); - - b.Property("Created") - .HasColumnType("datetimeoffset"); - - b.Property("CreatedBy") - .HasColumnType("nvarchar(max)"); - - b.Property("Currency") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("IsConfirmed") - .HasColumnType("bit"); - - b.Property("LastModified") - .HasColumnType("datetimeoffset"); - - b.Property("LastModifiedBy") - .HasColumnType("nvarchar(max)"); - - b.Property("Paid") - .HasColumnType("bit"); - - b.Property("StripeBillingDetailEmail") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("StripeBillingDetailName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("StripeChargeId") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("StripeEventId") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("StripePaymentIntent") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("StripePaymentMethod") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("StripeReceiptUrl") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("TipMessage") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.HasIndex("ApplicationUserId"); - - b.ToTable("UserTransactions"); - }); - - modelBuilder.Entity("Hutopy.Infrastructure.Identity.ApplicationUser", b => - { - b.Property("Id") - .HasColumnType("nvarchar(450)"); - - b.Property("About") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("AccessFailedCount") - .HasColumnType("int"); - - b.Property("Address") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("BirthDate") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("City") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("ConcurrencyStamp") - .IsConcurrencyToken() - .HasColumnType("nvarchar(max)"); - - b.Property("Country") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Description") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Email") - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.Property("EmailConfirmed") - .HasColumnType("bit"); - - b.Property("FirstName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("LastName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("LockoutEnabled") - .HasColumnType("bit"); - - b.Property("LockoutEnd") - .HasColumnType("datetimeoffset"); - - b.Property("NormalizedEmail") - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.Property("NormalizedUserName") - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.Property("Occupation") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("PasswordHash") - .HasColumnType("nvarchar(max)"); - - b.Property("PhoneNumber") - .HasColumnType("nvarchar(max)"); - - b.Property("PhoneNumberConfirmed") - .HasColumnType("bit"); - - b.Property("PortraitUrl") - .HasColumnType("nvarchar(max)"); - - b.Property("SecurityStamp") - .HasColumnType("nvarchar(max)"); - - b.Property("TwoFactorEnabled") - .HasColumnType("bit"); - - b.Property("UserName") - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.HasKey("Id"); - - b.HasIndex("NormalizedEmail") - .HasDatabaseName("EmailIndex"); - - b.HasIndex("NormalizedUserName") - .IsUnique() - .HasDatabaseName("UserNameIndex") - .HasFilter("[NormalizedUserName] IS NOT NULL"); - - b.ToTable("AspNetUsers", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b => - { - b.Property("Id") - .HasColumnType("nvarchar(450)"); - - b.Property("ConcurrencyStamp") - .IsConcurrencyToken() - .HasColumnType("nvarchar(max)"); - - b.Property("Name") - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.Property("NormalizedName") - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.HasKey("Id"); - - b.HasIndex("NormalizedName") - .IsUnique() - .HasDatabaseName("RoleNameIndex") - .HasFilter("[NormalizedName] IS NOT NULL"); - - b.ToTable("AspNetRoles", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ClaimType") - .HasColumnType("nvarchar(max)"); - - b.Property("ClaimValue") - .HasColumnType("nvarchar(max)"); - - b.Property("RoleId") - .IsRequired() - .HasColumnType("nvarchar(450)"); - - b.HasKey("Id"); - - b.HasIndex("RoleId"); - - b.ToTable("AspNetRoleClaims", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ClaimType") - .HasColumnType("nvarchar(max)"); - - b.Property("ClaimValue") - .HasColumnType("nvarchar(max)"); - - b.Property("UserId") - .IsRequired() - .HasColumnType("nvarchar(450)"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("AspNetUserClaims", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => - { - b.Property("LoginProvider") - .HasColumnType("nvarchar(450)"); - - b.Property("ProviderKey") - .HasColumnType("nvarchar(450)"); - - b.Property("ProviderDisplayName") - .HasColumnType("nvarchar(max)"); - - b.Property("UserId") - .IsRequired() - .HasColumnType("nvarchar(450)"); - - b.HasKey("LoginProvider", "ProviderKey"); - - b.HasIndex("UserId"); - - b.ToTable("AspNetUserLogins", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => - { - b.Property("UserId") - .HasColumnType("nvarchar(450)"); - - b.Property("RoleId") - .HasColumnType("nvarchar(450)"); - - b.HasKey("UserId", "RoleId"); - - b.HasIndex("RoleId"); - - b.ToTable("AspNetUserRoles", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => - { - b.Property("UserId") - .HasColumnType("nvarchar(450)"); - - b.Property("LoginProvider") - .HasColumnType("nvarchar(450)"); - - b.Property("Name") - .HasColumnType("nvarchar(450)"); - - b.Property("Value") - .HasColumnType("nvarchar(max)"); - - b.HasKey("UserId", "LoginProvider", "Name"); - - b.ToTable("AspNetUserTokens", (string)null); - }); - - modelBuilder.Entity("Hutopy.Domain.Entities.UserTransaction", b => - { - b.HasOne("Hutopy.Infrastructure.Identity.ApplicationUser", null) - .WithMany() - .HasForeignKey("ApplicationUserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Hutopy.Infrastructure.Identity.ApplicationUser", b => - { - b.OwnsOne("Hutopy.Infrastructure.Identity.OwnedEntities.SocialNetworks", "SocialNetworks", b1 => - { - b1.Property("ApplicationUserId") - .HasColumnType("nvarchar(450)"); - - b1.Property("FacebookUrl") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("InstagramUrl") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("LinkedInUrl") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("RedditUrl") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("TikTokUrl") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("XUrl") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("YourWebsiteUrl") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("YoutubeUrl") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.HasKey("ApplicationUserId"); - - b1.ToTable("ApplicationUser_SocialNetworks", (string)null); - - b1.WithOwner() - .HasForeignKey("ApplicationUserId"); - }); - - b.Navigation("SocialNetworks") - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => - { - b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) - .WithMany() - .HasForeignKey("RoleId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => - { - b.HasOne("Hutopy.Infrastructure.Identity.ApplicationUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => - { - b.HasOne("Hutopy.Infrastructure.Identity.ApplicationUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => - { - b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) - .WithMany() - .HasForeignKey("RoleId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Hutopy.Infrastructure.Identity.ApplicationUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => - { - b.HasOne("Hutopy.Infrastructure.Identity.ApplicationUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/Infrastructure/Migrations/20240701072549_AddPortraitUrlToUser.cs b/src/Infrastructure/Migrations/20240701072549_AddPortraitUrlToUser.cs deleted file mode 100644 index a279865..0000000 --- a/src/Infrastructure/Migrations/20240701072549_AddPortraitUrlToUser.cs +++ /dev/null @@ -1,28 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Hutopy.Infrastructure.Migrations -{ - /// - public partial class AddPortraitUrlToUser : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "PortraitUrl", - table: "AspNetUsers", - type: "nvarchar(max)", - nullable: true); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "PortraitUrl", - table: "AspNetUsers"); - } - } -} diff --git a/src/Infrastructure/Migrations/20240702055858_AddCreatorAliasTouser.Designer.cs b/src/Infrastructure/Migrations/20240702055858_AddCreatorAliasTouser.Designer.cs deleted file mode 100644 index 47946f4..0000000 --- a/src/Infrastructure/Migrations/20240702055858_AddCreatorAliasTouser.Designer.cs +++ /dev/null @@ -1,560 +0,0 @@ -// -using System; -using Hutopy.Infrastructure.Data; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -#nullable disable - -namespace Hutopy.Infrastructure.Migrations -{ - [DbContext(typeof(ApplicationDbContext))] - [Migration("20240702055858_AddCreatorAliasTouser")] - partial class AddCreatorAliasTouser - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "8.0.3") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); - - modelBuilder.Entity("Hutopy.Domain.Entities.FutureCreator", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier"); - - b.Property("Created") - .HasColumnType("datetimeoffset"); - - b.Property("CreatedBy") - .HasColumnType("nvarchar(max)"); - - b.Property("EmailAddress") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("FirstName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("LastModified") - .HasColumnType("datetimeoffset"); - - b.Property("LastModifiedBy") - .HasColumnType("nvarchar(max)"); - - b.Property("LastName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("PhoneNumber") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("ReasonToJoin") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("SocialNetworkAccount") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.ToTable("FutureCreators"); - }); - - modelBuilder.Entity("Hutopy.Domain.Entities.UserTransaction", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier"); - - b.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b.Property("ApplicationUserId") - .IsRequired() - .HasColumnType("nvarchar(450)"); - - b.Property("Created") - .HasColumnType("datetimeoffset"); - - b.Property("CreatedBy") - .HasColumnType("nvarchar(max)"); - - b.Property("Currency") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("IsConfirmed") - .HasColumnType("bit"); - - b.Property("LastModified") - .HasColumnType("datetimeoffset"); - - b.Property("LastModifiedBy") - .HasColumnType("nvarchar(max)"); - - b.Property("Paid") - .HasColumnType("bit"); - - b.Property("StripeBillingDetailEmail") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("StripeBillingDetailName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("StripeChargeId") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("StripeEventId") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("StripePaymentIntent") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("StripePaymentMethod") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("StripeReceiptUrl") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("TipMessage") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.HasIndex("ApplicationUserId"); - - b.ToTable("UserTransactions"); - }); - - modelBuilder.Entity("Hutopy.Infrastructure.Identity.ApplicationUser", b => - { - b.Property("Id") - .HasColumnType("nvarchar(450)"); - - b.Property("About") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("AccessFailedCount") - .HasColumnType("int"); - - b.Property("Address") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("BirthDate") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("City") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("ConcurrencyStamp") - .IsConcurrencyToken() - .HasColumnType("nvarchar(max)"); - - b.Property("Country") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("CreatorAlias") - .HasColumnType("nvarchar(max)"); - - b.Property("Description") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Email") - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.Property("EmailConfirmed") - .HasColumnType("bit"); - - b.Property("FirstName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("LastName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("LockoutEnabled") - .HasColumnType("bit"); - - b.Property("LockoutEnd") - .HasColumnType("datetimeoffset"); - - b.Property("NormalizedEmail") - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.Property("NormalizedUserName") - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.Property("Occupation") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("PasswordHash") - .HasColumnType("nvarchar(max)"); - - b.Property("PhoneNumber") - .HasColumnType("nvarchar(max)"); - - b.Property("PhoneNumberConfirmed") - .HasColumnType("bit"); - - b.Property("SecurityStamp") - .HasColumnType("nvarchar(max)"); - - b.Property("TwoFactorEnabled") - .HasColumnType("bit"); - - b.Property("UserName") - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.HasKey("Id"); - - b.HasIndex("NormalizedEmail") - .HasDatabaseName("EmailIndex"); - - b.HasIndex("NormalizedUserName") - .IsUnique() - .HasDatabaseName("UserNameIndex") - .HasFilter("[NormalizedUserName] IS NOT NULL"); - - b.ToTable("AspNetUsers", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b => - { - b.Property("Id") - .HasColumnType("nvarchar(450)"); - - b.Property("ConcurrencyStamp") - .IsConcurrencyToken() - .HasColumnType("nvarchar(max)"); - - b.Property("Name") - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.Property("NormalizedName") - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.HasKey("Id"); - - b.HasIndex("NormalizedName") - .IsUnique() - .HasDatabaseName("RoleNameIndex") - .HasFilter("[NormalizedName] IS NOT NULL"); - - b.ToTable("AspNetRoles", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ClaimType") - .HasColumnType("nvarchar(max)"); - - b.Property("ClaimValue") - .HasColumnType("nvarchar(max)"); - - b.Property("RoleId") - .IsRequired() - .HasColumnType("nvarchar(450)"); - - b.HasKey("Id"); - - b.HasIndex("RoleId"); - - b.ToTable("AspNetRoleClaims", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ClaimType") - .HasColumnType("nvarchar(max)"); - - b.Property("ClaimValue") - .HasColumnType("nvarchar(max)"); - - b.Property("UserId") - .IsRequired() - .HasColumnType("nvarchar(450)"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("AspNetUserClaims", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => - { - b.Property("LoginProvider") - .HasColumnType("nvarchar(450)"); - - b.Property("ProviderKey") - .HasColumnType("nvarchar(450)"); - - b.Property("ProviderDisplayName") - .HasColumnType("nvarchar(max)"); - - b.Property("UserId") - .IsRequired() - .HasColumnType("nvarchar(450)"); - - b.HasKey("LoginProvider", "ProviderKey"); - - b.HasIndex("UserId"); - - b.ToTable("AspNetUserLogins", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => - { - b.Property("UserId") - .HasColumnType("nvarchar(450)"); - - b.Property("RoleId") - .HasColumnType("nvarchar(450)"); - - b.HasKey("UserId", "RoleId"); - - b.HasIndex("RoleId"); - - b.ToTable("AspNetUserRoles", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => - { - b.Property("UserId") - .HasColumnType("nvarchar(450)"); - - b.Property("LoginProvider") - .HasColumnType("nvarchar(450)"); - - b.Property("Name") - .HasColumnType("nvarchar(450)"); - - b.Property("Value") - .HasColumnType("nvarchar(max)"); - - b.HasKey("UserId", "LoginProvider", "Name"); - - b.ToTable("AspNetUserTokens", (string)null); - }); - - modelBuilder.Entity("Hutopy.Domain.Entities.UserTransaction", b => - { - b.HasOne("Hutopy.Infrastructure.Identity.ApplicationUser", null) - .WithMany() - .HasForeignKey("ApplicationUserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Hutopy.Infrastructure.Identity.ApplicationUser", b => - { - b.OwnsOne("Hutopy.Infrastructure.Identity.OwnedEntities.ProfileColors", "ProfileColors", b1 => - { - b1.Property("ApplicationUserId") - .HasColumnType("nvarchar(450)"); - - b1.Property("Accent") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("BannerBottom") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("BannerTop") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("Menu") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.HasKey("ApplicationUserId"); - - b1.ToTable("ApplicationUser_ProfileColors", (string)null); - - b1.WithOwner() - .HasForeignKey("ApplicationUserId"); - }); - - b.OwnsOne("Hutopy.Infrastructure.Identity.OwnedEntities.SocialNetworks", "SocialNetworks", b1 => - { - b1.Property("ApplicationUserId") - .HasColumnType("nvarchar(450)"); - - b1.Property("FacebookUrl") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("InstagramUrl") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("LinkedInUrl") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("RedditUrl") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("TikTokUrl") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("XUrl") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("YourWebsiteUrl") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("YoutubeUrl") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.HasKey("ApplicationUserId"); - - b1.ToTable("ApplicationUser_SocialNetworks", (string)null); - - b1.WithOwner() - .HasForeignKey("ApplicationUserId"); - }); - - b.OwnsOne("Hutopy.Infrastructure.Identity.OwnedEntities.StoredDataUrls", "StoredDataUrls", b1 => - { - b1.Property("ApplicationUserId") - .HasColumnType("nvarchar(450)"); - - b1.Property("BannerPictureUrl") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("ProfilePictureUrl") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("WebsiteIconUrl") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.HasKey("ApplicationUserId"); - - b1.ToTable("ApplicationUser_StoredDataUrls", (string)null); - - b1.WithOwner() - .HasForeignKey("ApplicationUserId"); - }); - - b.Navigation("ProfileColors") - .IsRequired(); - - b.Navigation("SocialNetworks") - .IsRequired(); - - b.Navigation("StoredDataUrls") - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => - { - b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) - .WithMany() - .HasForeignKey("RoleId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => - { - b.HasOne("Hutopy.Infrastructure.Identity.ApplicationUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => - { - b.HasOne("Hutopy.Infrastructure.Identity.ApplicationUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => - { - b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) - .WithMany() - .HasForeignKey("RoleId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Hutopy.Infrastructure.Identity.ApplicationUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => - { - b.HasOne("Hutopy.Infrastructure.Identity.ApplicationUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/Infrastructure/Migrations/20240702055858_AddCreatorAliasTouser.cs b/src/Infrastructure/Migrations/20240702055858_AddCreatorAliasTouser.cs deleted file mode 100644 index 456b236..0000000 --- a/src/Infrastructure/Migrations/20240702055858_AddCreatorAliasTouser.cs +++ /dev/null @@ -1,28 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Hutopy.Infrastructure.Migrations -{ - /// - public partial class AddCreatorAliasTouser : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "CreatorAlias", - table: "AspNetUsers", - type: "nvarchar(max)", - nullable: true); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "CreatorAlias", - table: "AspNetUsers"); - } - } -} diff --git a/src/Infrastructure/Migrations/20240705010235_RemovePortraitUrl.Designer.cs b/src/Infrastructure/Migrations/20240705010235_RemovePortraitUrl.Designer.cs deleted file mode 100644 index 1df55e6..0000000 --- a/src/Infrastructure/Migrations/20240705010235_RemovePortraitUrl.Designer.cs +++ /dev/null @@ -1,560 +0,0 @@ -// -using System; -using Hutopy.Infrastructure.Data; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -#nullable disable - -namespace Hutopy.Infrastructure.Migrations -{ - [DbContext(typeof(ApplicationDbContext))] - [Migration("20240705010235_RemovePortraitUrl")] - partial class RemovePortraitUrl - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "8.0.3") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); - - modelBuilder.Entity("Hutopy.Domain.Entities.FutureCreator", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier"); - - b.Property("Created") - .HasColumnType("datetimeoffset"); - - b.Property("CreatedBy") - .HasColumnType("nvarchar(max)"); - - b.Property("EmailAddress") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("FirstName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("LastModified") - .HasColumnType("datetimeoffset"); - - b.Property("LastModifiedBy") - .HasColumnType("nvarchar(max)"); - - b.Property("LastName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("PhoneNumber") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("ReasonToJoin") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("SocialNetworkAccount") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.ToTable("FutureCreators"); - }); - - modelBuilder.Entity("Hutopy.Domain.Entities.UserTransaction", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier"); - - b.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b.Property("ApplicationUserId") - .IsRequired() - .HasColumnType("nvarchar(450)"); - - b.Property("Created") - .HasColumnType("datetimeoffset"); - - b.Property("CreatedBy") - .HasColumnType("nvarchar(max)"); - - b.Property("Currency") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("IsConfirmed") - .HasColumnType("bit"); - - b.Property("LastModified") - .HasColumnType("datetimeoffset"); - - b.Property("LastModifiedBy") - .HasColumnType("nvarchar(max)"); - - b.Property("Paid") - .HasColumnType("bit"); - - b.Property("StripeBillingDetailEmail") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("StripeBillingDetailName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("StripeChargeId") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("StripeEventId") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("StripePaymentIntent") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("StripePaymentMethod") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("StripeReceiptUrl") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("TipMessage") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.HasIndex("ApplicationUserId"); - - b.ToTable("UserTransactions"); - }); - - modelBuilder.Entity("Hutopy.Infrastructure.Identity.ApplicationUser", b => - { - b.Property("Id") - .HasColumnType("nvarchar(450)"); - - b.Property("About") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("AccessFailedCount") - .HasColumnType("int"); - - b.Property("Address") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("BirthDate") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("City") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("ConcurrencyStamp") - .IsConcurrencyToken() - .HasColumnType("nvarchar(max)"); - - b.Property("Country") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("CreatorAlias") - .HasColumnType("nvarchar(max)"); - - b.Property("Description") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Email") - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.Property("EmailConfirmed") - .HasColumnType("bit"); - - b.Property("FirstName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("LastName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("LockoutEnabled") - .HasColumnType("bit"); - - b.Property("LockoutEnd") - .HasColumnType("datetimeoffset"); - - b.Property("NormalizedEmail") - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.Property("NormalizedUserName") - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.Property("Occupation") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("PasswordHash") - .HasColumnType("nvarchar(max)"); - - b.Property("PhoneNumber") - .HasColumnType("nvarchar(max)"); - - b.Property("PhoneNumberConfirmed") - .HasColumnType("bit"); - - b.Property("SecurityStamp") - .HasColumnType("nvarchar(max)"); - - b.Property("TwoFactorEnabled") - .HasColumnType("bit"); - - b.Property("UserName") - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.HasKey("Id"); - - b.HasIndex("NormalizedEmail") - .HasDatabaseName("EmailIndex"); - - b.HasIndex("NormalizedUserName") - .IsUnique() - .HasDatabaseName("UserNameIndex") - .HasFilter("[NormalizedUserName] IS NOT NULL"); - - b.ToTable("AspNetUsers", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b => - { - b.Property("Id") - .HasColumnType("nvarchar(450)"); - - b.Property("ConcurrencyStamp") - .IsConcurrencyToken() - .HasColumnType("nvarchar(max)"); - - b.Property("Name") - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.Property("NormalizedName") - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.HasKey("Id"); - - b.HasIndex("NormalizedName") - .IsUnique() - .HasDatabaseName("RoleNameIndex") - .HasFilter("[NormalizedName] IS NOT NULL"); - - b.ToTable("AspNetRoles", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ClaimType") - .HasColumnType("nvarchar(max)"); - - b.Property("ClaimValue") - .HasColumnType("nvarchar(max)"); - - b.Property("RoleId") - .IsRequired() - .HasColumnType("nvarchar(450)"); - - b.HasKey("Id"); - - b.HasIndex("RoleId"); - - b.ToTable("AspNetRoleClaims", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ClaimType") - .HasColumnType("nvarchar(max)"); - - b.Property("ClaimValue") - .HasColumnType("nvarchar(max)"); - - b.Property("UserId") - .IsRequired() - .HasColumnType("nvarchar(450)"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("AspNetUserClaims", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => - { - b.Property("LoginProvider") - .HasColumnType("nvarchar(450)"); - - b.Property("ProviderKey") - .HasColumnType("nvarchar(450)"); - - b.Property("ProviderDisplayName") - .HasColumnType("nvarchar(max)"); - - b.Property("UserId") - .IsRequired() - .HasColumnType("nvarchar(450)"); - - b.HasKey("LoginProvider", "ProviderKey"); - - b.HasIndex("UserId"); - - b.ToTable("AspNetUserLogins", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => - { - b.Property("UserId") - .HasColumnType("nvarchar(450)"); - - b.Property("RoleId") - .HasColumnType("nvarchar(450)"); - - b.HasKey("UserId", "RoleId"); - - b.HasIndex("RoleId"); - - b.ToTable("AspNetUserRoles", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => - { - b.Property("UserId") - .HasColumnType("nvarchar(450)"); - - b.Property("LoginProvider") - .HasColumnType("nvarchar(450)"); - - b.Property("Name") - .HasColumnType("nvarchar(450)"); - - b.Property("Value") - .HasColumnType("nvarchar(max)"); - - b.HasKey("UserId", "LoginProvider", "Name"); - - b.ToTable("AspNetUserTokens", (string)null); - }); - - modelBuilder.Entity("Hutopy.Domain.Entities.UserTransaction", b => - { - b.HasOne("Hutopy.Infrastructure.Identity.ApplicationUser", null) - .WithMany() - .HasForeignKey("ApplicationUserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Hutopy.Infrastructure.Identity.ApplicationUser", b => - { - b.OwnsOne("Hutopy.Infrastructure.Identity.OwnedEntities.ProfileColors", "ProfileColors", b1 => - { - b1.Property("ApplicationUserId") - .HasColumnType("nvarchar(450)"); - - b1.Property("Accent") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("BannerBottom") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("BannerTop") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("Menu") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.HasKey("ApplicationUserId"); - - b1.ToTable("ApplicationUser_ProfileColors", (string)null); - - b1.WithOwner() - .HasForeignKey("ApplicationUserId"); - }); - - b.OwnsOne("Hutopy.Infrastructure.Identity.OwnedEntities.SocialNetworks", "SocialNetworks", b1 => - { - b1.Property("ApplicationUserId") - .HasColumnType("nvarchar(450)"); - - b1.Property("FacebookUrl") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("InstagramUrl") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("LinkedInUrl") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("RedditUrl") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("TikTokUrl") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("XUrl") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("YourWebsiteUrl") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("YoutubeUrl") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.HasKey("ApplicationUserId"); - - b1.ToTable("ApplicationUser_SocialNetworks", (string)null); - - b1.WithOwner() - .HasForeignKey("ApplicationUserId"); - }); - - b.OwnsOne("Hutopy.Infrastructure.Identity.OwnedEntities.StoredDataUrls", "StoredDataUrls", b1 => - { - b1.Property("ApplicationUserId") - .HasColumnType("nvarchar(450)"); - - b1.Property("BannerPictureUrl") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("ProfilePictureUrl") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("WebsiteIconUrl") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.HasKey("ApplicationUserId"); - - b1.ToTable("ApplicationUser_StoredDataUrls", (string)null); - - b1.WithOwner() - .HasForeignKey("ApplicationUserId"); - }); - - b.Navigation("ProfileColors") - .IsRequired(); - - b.Navigation("SocialNetworks") - .IsRequired(); - - b.Navigation("StoredDataUrls") - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => - { - b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) - .WithMany() - .HasForeignKey("RoleId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => - { - b.HasOne("Hutopy.Infrastructure.Identity.ApplicationUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => - { - b.HasOne("Hutopy.Infrastructure.Identity.ApplicationUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => - { - b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) - .WithMany() - .HasForeignKey("RoleId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Hutopy.Infrastructure.Identity.ApplicationUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => - { - b.HasOne("Hutopy.Infrastructure.Identity.ApplicationUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/Infrastructure/Migrations/20240705010235_RemovePortraitUrl.cs b/src/Infrastructure/Migrations/20240705010235_RemovePortraitUrl.cs deleted file mode 100644 index e504870..0000000 --- a/src/Infrastructure/Migrations/20240705010235_RemovePortraitUrl.cs +++ /dev/null @@ -1,28 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Hutopy.Infrastructure.Migrations -{ - /// - public partial class RemovePortraitUrl : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "PortraitUrl", - table: "AspNetUsers"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "PortraitUrl", - table: "AspNetUsers", - type: "nvarchar(max)", - nullable: true); - } - } -} diff --git a/src/Infrastructure/Migrations/20240721045147_AddAlias.Designer.cs b/src/Infrastructure/Migrations/20240721045147_AddAlias.Designer.cs deleted file mode 100644 index 397d04b..0000000 --- a/src/Infrastructure/Migrations/20240721045147_AddAlias.Designer.cs +++ /dev/null @@ -1,563 +0,0 @@ -// -using System; -using Hutopy.Infrastructure.Data; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -#nullable disable - -namespace Hutopy.Infrastructure.Migrations -{ - [DbContext(typeof(ApplicationDbContext))] - [Migration("20240721045147_AddAlias")] - partial class AddAlias - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "8.0.4") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); - - modelBuilder.Entity("Hutopy.Domain.Entities.FutureCreator", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier"); - - b.Property("Created") - .HasColumnType("datetimeoffset"); - - b.Property("CreatedBy") - .HasColumnType("nvarchar(max)"); - - b.Property("EmailAddress") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("FirstName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("LastModified") - .HasColumnType("datetimeoffset"); - - b.Property("LastModifiedBy") - .HasColumnType("nvarchar(max)"); - - b.Property("LastName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("PhoneNumber") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("ReasonToJoin") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("SocialNetworkAccount") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.ToTable("FutureCreators"); - }); - - modelBuilder.Entity("Hutopy.Domain.Entities.UserTransaction", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier"); - - b.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b.Property("ApplicationUserId") - .IsRequired() - .HasColumnType("nvarchar(450)"); - - b.Property("Created") - .HasColumnType("datetimeoffset"); - - b.Property("CreatedBy") - .HasColumnType("nvarchar(max)"); - - b.Property("Currency") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("IsConfirmed") - .HasColumnType("bit"); - - b.Property("LastModified") - .HasColumnType("datetimeoffset"); - - b.Property("LastModifiedBy") - .HasColumnType("nvarchar(max)"); - - b.Property("Paid") - .HasColumnType("bit"); - - b.Property("StripeBillingDetailEmail") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("StripeBillingDetailName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("StripeChargeId") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("StripeEventId") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("StripePaymentIntent") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("StripePaymentMethod") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("StripeReceiptUrl") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("TipMessage") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.HasIndex("ApplicationUserId"); - - b.ToTable("UserTransactions"); - }); - - modelBuilder.Entity("Hutopy.Infrastructure.Identity.ApplicationUser", b => - { - b.Property("Id") - .HasColumnType("nvarchar(450)"); - - b.Property("About") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("AccessFailedCount") - .HasColumnType("int"); - - b.Property("Address") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Alias") - .HasColumnType("nvarchar(max)"); - - b.Property("BirthDate") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("City") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("ConcurrencyStamp") - .IsConcurrencyToken() - .HasColumnType("nvarchar(max)"); - - b.Property("Country") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("CreatorAlias") - .HasColumnType("nvarchar(max)"); - - b.Property("Description") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Email") - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.Property("EmailConfirmed") - .HasColumnType("bit"); - - b.Property("FirstName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("LastName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("LockoutEnabled") - .HasColumnType("bit"); - - b.Property("LockoutEnd") - .HasColumnType("datetimeoffset"); - - b.Property("NormalizedEmail") - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.Property("NormalizedUserName") - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.Property("Occupation") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("PasswordHash") - .HasColumnType("nvarchar(max)"); - - b.Property("PhoneNumber") - .HasColumnType("nvarchar(max)"); - - b.Property("PhoneNumberConfirmed") - .HasColumnType("bit"); - - b.Property("SecurityStamp") - .HasColumnType("nvarchar(max)"); - - b.Property("TwoFactorEnabled") - .HasColumnType("bit"); - - b.Property("UserName") - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.HasKey("Id"); - - b.HasIndex("NormalizedEmail") - .HasDatabaseName("EmailIndex"); - - b.HasIndex("NormalizedUserName") - .IsUnique() - .HasDatabaseName("UserNameIndex") - .HasFilter("[NormalizedUserName] IS NOT NULL"); - - b.ToTable("AspNetUsers", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b => - { - b.Property("Id") - .HasColumnType("nvarchar(450)"); - - b.Property("ConcurrencyStamp") - .IsConcurrencyToken() - .HasColumnType("nvarchar(max)"); - - b.Property("Name") - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.Property("NormalizedName") - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.HasKey("Id"); - - b.HasIndex("NormalizedName") - .IsUnique() - .HasDatabaseName("RoleNameIndex") - .HasFilter("[NormalizedName] IS NOT NULL"); - - b.ToTable("AspNetRoles", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ClaimType") - .HasColumnType("nvarchar(max)"); - - b.Property("ClaimValue") - .HasColumnType("nvarchar(max)"); - - b.Property("RoleId") - .IsRequired() - .HasColumnType("nvarchar(450)"); - - b.HasKey("Id"); - - b.HasIndex("RoleId"); - - b.ToTable("AspNetRoleClaims", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ClaimType") - .HasColumnType("nvarchar(max)"); - - b.Property("ClaimValue") - .HasColumnType("nvarchar(max)"); - - b.Property("UserId") - .IsRequired() - .HasColumnType("nvarchar(450)"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("AspNetUserClaims", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => - { - b.Property("LoginProvider") - .HasColumnType("nvarchar(450)"); - - b.Property("ProviderKey") - .HasColumnType("nvarchar(450)"); - - b.Property("ProviderDisplayName") - .HasColumnType("nvarchar(max)"); - - b.Property("UserId") - .IsRequired() - .HasColumnType("nvarchar(450)"); - - b.HasKey("LoginProvider", "ProviderKey"); - - b.HasIndex("UserId"); - - b.ToTable("AspNetUserLogins", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => - { - b.Property("UserId") - .HasColumnType("nvarchar(450)"); - - b.Property("RoleId") - .HasColumnType("nvarchar(450)"); - - b.HasKey("UserId", "RoleId"); - - b.HasIndex("RoleId"); - - b.ToTable("AspNetUserRoles", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => - { - b.Property("UserId") - .HasColumnType("nvarchar(450)"); - - b.Property("LoginProvider") - .HasColumnType("nvarchar(450)"); - - b.Property("Name") - .HasColumnType("nvarchar(450)"); - - b.Property("Value") - .HasColumnType("nvarchar(max)"); - - b.HasKey("UserId", "LoginProvider", "Name"); - - b.ToTable("AspNetUserTokens", (string)null); - }); - - modelBuilder.Entity("Hutopy.Domain.Entities.UserTransaction", b => - { - b.HasOne("Hutopy.Infrastructure.Identity.ApplicationUser", null) - .WithMany() - .HasForeignKey("ApplicationUserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Hutopy.Infrastructure.Identity.ApplicationUser", b => - { - b.OwnsOne("Hutopy.Infrastructure.Identity.OwnedEntities.ProfileColors", "ProfileColors", b1 => - { - b1.Property("ApplicationUserId") - .HasColumnType("nvarchar(450)"); - - b1.Property("Accent") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("BannerBottom") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("BannerTop") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("Menu") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.HasKey("ApplicationUserId"); - - b1.ToTable("ApplicationUser_ProfileColors", (string)null); - - b1.WithOwner() - .HasForeignKey("ApplicationUserId"); - }); - - b.OwnsOne("Hutopy.Infrastructure.Identity.OwnedEntities.SocialNetworks", "SocialNetworks", b1 => - { - b1.Property("ApplicationUserId") - .HasColumnType("nvarchar(450)"); - - b1.Property("FacebookUrl") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("InstagramUrl") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("LinkedInUrl") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("RedditUrl") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("TikTokUrl") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("XUrl") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("YourWebsiteUrl") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("YoutubeUrl") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.HasKey("ApplicationUserId"); - - b1.ToTable("ApplicationUser_SocialNetworks", (string)null); - - b1.WithOwner() - .HasForeignKey("ApplicationUserId"); - }); - - b.OwnsOne("Hutopy.Infrastructure.Identity.OwnedEntities.StoredDataUrls", "StoredDataUrls", b1 => - { - b1.Property("ApplicationUserId") - .HasColumnType("nvarchar(450)"); - - b1.Property("BannerPictureUrl") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("ProfilePictureUrl") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("WebsiteIconUrl") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.HasKey("ApplicationUserId"); - - b1.ToTable("ApplicationUser_StoredDataUrls", (string)null); - - b1.WithOwner() - .HasForeignKey("ApplicationUserId"); - }); - - b.Navigation("ProfileColors") - .IsRequired(); - - b.Navigation("SocialNetworks") - .IsRequired(); - - b.Navigation("StoredDataUrls") - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => - { - b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) - .WithMany() - .HasForeignKey("RoleId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => - { - b.HasOne("Hutopy.Infrastructure.Identity.ApplicationUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => - { - b.HasOne("Hutopy.Infrastructure.Identity.ApplicationUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => - { - b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) - .WithMany() - .HasForeignKey("RoleId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Hutopy.Infrastructure.Identity.ApplicationUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => - { - b.HasOne("Hutopy.Infrastructure.Identity.ApplicationUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/Infrastructure/Migrations/20240721045147_AddAlias.cs b/src/Infrastructure/Migrations/20240721045147_AddAlias.cs deleted file mode 100644 index 9c8ffc9..0000000 --- a/src/Infrastructure/Migrations/20240721045147_AddAlias.cs +++ /dev/null @@ -1,28 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Hutopy.Infrastructure.Migrations -{ - /// - public partial class AddAlias : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "Alias", - table: "AspNetUsers", - type: "nvarchar(max)", - nullable: true); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "Alias", - table: "AspNetUsers"); - } - } -} diff --git a/src/Infrastructure/Migrations/20240721063535_MadeOptional_StoredDataUrls.Designer.cs b/src/Infrastructure/Migrations/20240721063535_MadeOptional_StoredDataUrls.Designer.cs deleted file mode 100644 index 142d953..0000000 --- a/src/Infrastructure/Migrations/20240721063535_MadeOptional_StoredDataUrls.Designer.cs +++ /dev/null @@ -1,563 +0,0 @@ -// -using System; -using Hutopy.Infrastructure.Data; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -#nullable disable - -namespace Hutopy.Infrastructure.Migrations -{ - [DbContext(typeof(ApplicationDbContext))] - [Migration("20240721063535_MadeOptional_StoredDataUrls")] - partial class MadeOptional_StoredDataUrls - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "8.0.4") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); - - modelBuilder.Entity("Hutopy.Domain.Entities.FutureCreator", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier"); - - b.Property("Created") - .HasColumnType("datetimeoffset"); - - b.Property("CreatedBy") - .HasColumnType("nvarchar(max)"); - - b.Property("EmailAddress") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("FirstName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("LastModified") - .HasColumnType("datetimeoffset"); - - b.Property("LastModifiedBy") - .HasColumnType("nvarchar(max)"); - - b.Property("LastName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("PhoneNumber") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("ReasonToJoin") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("SocialNetworkAccount") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.ToTable("FutureCreators"); - }); - - modelBuilder.Entity("Hutopy.Domain.Entities.UserTransaction", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier"); - - b.Property("Amount") - .HasPrecision(18, 2) - .HasColumnType("decimal(18,2)"); - - b.Property("ApplicationUserId") - .IsRequired() - .HasColumnType("nvarchar(450)"); - - b.Property("Created") - .HasColumnType("datetimeoffset"); - - b.Property("CreatedBy") - .HasColumnType("nvarchar(max)"); - - b.Property("Currency") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("IsConfirmed") - .HasColumnType("bit"); - - b.Property("LastModified") - .HasColumnType("datetimeoffset"); - - b.Property("LastModifiedBy") - .HasColumnType("nvarchar(max)"); - - b.Property("Paid") - .HasColumnType("bit"); - - b.Property("StripeBillingDetailEmail") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("StripeBillingDetailName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("StripeChargeId") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("StripeEventId") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("StripePaymentIntent") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("StripePaymentMethod") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("StripeReceiptUrl") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("TipMessage") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.HasIndex("ApplicationUserId"); - - b.ToTable("UserTransactions"); - }); - - modelBuilder.Entity("Hutopy.Infrastructure.Identity.ApplicationUser", b => - { - b.Property("Id") - .HasColumnType("nvarchar(450)"); - - b.Property("About") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("AccessFailedCount") - .HasColumnType("int"); - - b.Property("Address") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Alias") - .HasColumnType("nvarchar(max)"); - - b.Property("BirthDate") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("City") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("ConcurrencyStamp") - .IsConcurrencyToken() - .HasColumnType("nvarchar(max)"); - - b.Property("Country") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("CreatorAlias") - .HasColumnType("nvarchar(max)"); - - b.Property("Description") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Email") - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.Property("EmailConfirmed") - .HasColumnType("bit"); - - b.Property("FirstName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("LastName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("LockoutEnabled") - .HasColumnType("bit"); - - b.Property("LockoutEnd") - .HasColumnType("datetimeoffset"); - - b.Property("NormalizedEmail") - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.Property("NormalizedUserName") - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.Property("Occupation") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("PasswordHash") - .HasColumnType("nvarchar(max)"); - - b.Property("PhoneNumber") - .HasColumnType("nvarchar(max)"); - - b.Property("PhoneNumberConfirmed") - .HasColumnType("bit"); - - b.Property("SecurityStamp") - .HasColumnType("nvarchar(max)"); - - b.Property("TwoFactorEnabled") - .HasColumnType("bit"); - - b.Property("UserName") - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.HasKey("Id"); - - b.HasIndex("NormalizedEmail") - .HasDatabaseName("EmailIndex"); - - b.HasIndex("NormalizedUserName") - .IsUnique() - .HasDatabaseName("UserNameIndex") - .HasFilter("[NormalizedUserName] IS NOT NULL"); - - b.ToTable("AspNetUsers", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b => - { - b.Property("Id") - .HasColumnType("nvarchar(450)"); - - b.Property("ConcurrencyStamp") - .IsConcurrencyToken() - .HasColumnType("nvarchar(max)"); - - b.Property("Name") - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.Property("NormalizedName") - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.HasKey("Id"); - - b.HasIndex("NormalizedName") - .IsUnique() - .HasDatabaseName("RoleNameIndex") - .HasFilter("[NormalizedName] IS NOT NULL"); - - b.ToTable("AspNetRoles", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ClaimType") - .HasColumnType("nvarchar(max)"); - - b.Property("ClaimValue") - .HasColumnType("nvarchar(max)"); - - b.Property("RoleId") - .IsRequired() - .HasColumnType("nvarchar(450)"); - - b.HasKey("Id"); - - b.HasIndex("RoleId"); - - b.ToTable("AspNetRoleClaims", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ClaimType") - .HasColumnType("nvarchar(max)"); - - b.Property("ClaimValue") - .HasColumnType("nvarchar(max)"); - - b.Property("UserId") - .IsRequired() - .HasColumnType("nvarchar(450)"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("AspNetUserClaims", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => - { - b.Property("LoginProvider") - .HasColumnType("nvarchar(450)"); - - b.Property("ProviderKey") - .HasColumnType("nvarchar(450)"); - - b.Property("ProviderDisplayName") - .HasColumnType("nvarchar(max)"); - - b.Property("UserId") - .IsRequired() - .HasColumnType("nvarchar(450)"); - - b.HasKey("LoginProvider", "ProviderKey"); - - b.HasIndex("UserId"); - - b.ToTable("AspNetUserLogins", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => - { - b.Property("UserId") - .HasColumnType("nvarchar(450)"); - - b.Property("RoleId") - .HasColumnType("nvarchar(450)"); - - b.HasKey("UserId", "RoleId"); - - b.HasIndex("RoleId"); - - b.ToTable("AspNetUserRoles", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => - { - b.Property("UserId") - .HasColumnType("nvarchar(450)"); - - b.Property("LoginProvider") - .HasColumnType("nvarchar(450)"); - - b.Property("Name") - .HasColumnType("nvarchar(450)"); - - b.Property("Value") - .HasColumnType("nvarchar(max)"); - - b.HasKey("UserId", "LoginProvider", "Name"); - - b.ToTable("AspNetUserTokens", (string)null); - }); - - modelBuilder.Entity("Hutopy.Domain.Entities.UserTransaction", b => - { - b.HasOne("Hutopy.Infrastructure.Identity.ApplicationUser", null) - .WithMany() - .HasForeignKey("ApplicationUserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Hutopy.Infrastructure.Identity.ApplicationUser", b => - { - b.OwnsOne("Hutopy.Infrastructure.Identity.OwnedEntities.ProfileColors", "ProfileColors", b1 => - { - b1.Property("ApplicationUserId") - .HasColumnType("nvarchar(450)"); - - b1.Property("Accent") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("BannerBottom") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("BannerTop") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("Menu") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.HasKey("ApplicationUserId"); - - b1.ToTable("ApplicationUser_ProfileColors", (string)null); - - b1.WithOwner() - .HasForeignKey("ApplicationUserId"); - }); - - b.OwnsOne("Hutopy.Infrastructure.Identity.OwnedEntities.SocialNetworks", "SocialNetworks", b1 => - { - b1.Property("ApplicationUserId") - .HasColumnType("nvarchar(450)"); - - b1.Property("FacebookUrl") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("InstagramUrl") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("LinkedInUrl") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("RedditUrl") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("TikTokUrl") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("XUrl") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("YourWebsiteUrl") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("YoutubeUrl") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.HasKey("ApplicationUserId"); - - b1.ToTable("ApplicationUser_SocialNetworks", (string)null); - - b1.WithOwner() - .HasForeignKey("ApplicationUserId"); - }); - - b.OwnsOne("Hutopy.Infrastructure.Identity.OwnedEntities.StoredDataUrls", "StoredDataUrls", b1 => - { - b1.Property("ApplicationUserId") - .HasColumnType("nvarchar(450)"); - - b1.Property("BannerPictureUrl") - .HasMaxLength(255) - .HasColumnType("nvarchar(255)"); - - b1.Property("ProfilePictureUrl") - .HasMaxLength(255) - .HasColumnType("nvarchar(255)"); - - b1.Property("WebsiteIconUrl") - .HasMaxLength(255) - .HasColumnType("nvarchar(255)"); - - b1.HasKey("ApplicationUserId"); - - b1.ToTable("ApplicationUser_StoredDataUrls", (string)null); - - b1.WithOwner() - .HasForeignKey("ApplicationUserId"); - }); - - b.Navigation("ProfileColors") - .IsRequired(); - - b.Navigation("SocialNetworks") - .IsRequired(); - - b.Navigation("StoredDataUrls") - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => - { - b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) - .WithMany() - .HasForeignKey("RoleId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => - { - b.HasOne("Hutopy.Infrastructure.Identity.ApplicationUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => - { - b.HasOne("Hutopy.Infrastructure.Identity.ApplicationUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => - { - b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) - .WithMany() - .HasForeignKey("RoleId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Hutopy.Infrastructure.Identity.ApplicationUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => - { - b.HasOne("Hutopy.Infrastructure.Identity.ApplicationUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/Infrastructure/Migrations/20240721063535_MadeOptional_StoredDataUrls.cs b/src/Infrastructure/Migrations/20240721063535_MadeOptional_StoredDataUrls.cs deleted file mode 100644 index b3085ae..0000000 --- a/src/Infrastructure/Migrations/20240721063535_MadeOptional_StoredDataUrls.cs +++ /dev/null @@ -1,78 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Hutopy.Infrastructure.Migrations -{ - /// - public partial class MadeOptional_StoredDataUrls : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AlterColumn( - name: "WebsiteIconUrl", - table: "ApplicationUser_StoredDataUrls", - type: "nvarchar(255)", - maxLength: 255, - nullable: true, - oldClrType: typeof(string), - oldType: "nvarchar(max)"); - - migrationBuilder.AlterColumn( - name: "ProfilePictureUrl", - table: "ApplicationUser_StoredDataUrls", - type: "nvarchar(255)", - maxLength: 255, - nullable: true, - oldClrType: typeof(string), - oldType: "nvarchar(max)"); - - migrationBuilder.AlterColumn( - name: "BannerPictureUrl", - table: "ApplicationUser_StoredDataUrls", - type: "nvarchar(255)", - maxLength: 255, - nullable: true, - oldClrType: typeof(string), - oldType: "nvarchar(max)"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.AlterColumn( - name: "WebsiteIconUrl", - table: "ApplicationUser_StoredDataUrls", - type: "nvarchar(max)", - nullable: false, - defaultValue: "", - oldClrType: typeof(string), - oldType: "nvarchar(255)", - oldMaxLength: 255, - oldNullable: true); - - migrationBuilder.AlterColumn( - name: "ProfilePictureUrl", - table: "ApplicationUser_StoredDataUrls", - type: "nvarchar(max)", - nullable: false, - defaultValue: "", - oldClrType: typeof(string), - oldType: "nvarchar(255)", - oldMaxLength: 255, - oldNullable: true); - - migrationBuilder.AlterColumn( - name: "BannerPictureUrl", - table: "ApplicationUser_StoredDataUrls", - type: "nvarchar(max)", - nullable: false, - defaultValue: "", - oldClrType: typeof(string), - oldType: "nvarchar(255)", - oldMaxLength: 255, - oldNullable: true); - } - } -} diff --git a/src/Infrastructure/Migrations/20240509215538_AddMoreInformationToTransaction.Designer.cs b/src/Infrastructure/Migrations/20240802044736_Initial.Designer.cs similarity index 77% rename from src/Infrastructure/Migrations/20240509215538_AddMoreInformationToTransaction.Designer.cs rename to src/Infrastructure/Migrations/20240802044736_Initial.Designer.cs index f8c9e81..ad817a1 100644 --- a/src/Infrastructure/Migrations/20240509215538_AddMoreInformationToTransaction.Designer.cs +++ b/src/Infrastructure/Migrations/20240802044736_Initial.Designer.cs @@ -12,15 +12,15 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion; namespace Hutopy.Infrastructure.Migrations { [DbContext(typeof(ApplicationDbContext))] - [Migration("20240509215538_AddMoreInformationToTransaction")] - partial class AddMoreInformationToTransaction + [Migration("20240802044736_Initial")] + partial class Initial { /// protected override void BuildTargetModel(ModelBuilder modelBuilder) { #pragma warning disable 612, 618 modelBuilder - .HasAnnotation("ProductVersion", "8.0.3") + .HasAnnotation("ProductVersion", "8.0.4") .HasAnnotation("Relational:MaxIdentifierLength", 128); SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); @@ -31,11 +31,11 @@ namespace Hutopy.Infrastructure.Migrations .ValueGeneratedOnAdd() .HasColumnType("uniqueidentifier"); - b.Property("Created") + b.Property("CreatedAt") .HasColumnType("datetimeoffset"); - b.Property("CreatedBy") - .HasColumnType("nvarchar(max)"); + b.Property("CreatedBy") + .HasColumnType("uniqueidentifier"); b.Property("EmailAddress") .IsRequired() @@ -45,11 +45,11 @@ namespace Hutopy.Infrastructure.Migrations .IsRequired() .HasColumnType("nvarchar(max)"); - b.Property("LastModified") + b.Property("LastModifiedAt") .HasColumnType("datetimeoffset"); - b.Property("LastModifiedBy") - .HasColumnType("nvarchar(max)"); + b.Property("LastModifiedBy") + .HasColumnType("uniqueidentifier"); b.Property("LastName") .IsRequired() @@ -82,15 +82,14 @@ namespace Hutopy.Infrastructure.Migrations .HasPrecision(18, 2) .HasColumnType("decimal(18,2)"); - b.Property("ApplicationUserId") - .IsRequired() - .HasColumnType("nvarchar(450)"); + b.Property("ApplicationUserId") + .HasColumnType("uniqueidentifier"); - b.Property("Created") + b.Property("CreatedAt") .HasColumnType("datetimeoffset"); - b.Property("CreatedBy") - .HasColumnType("nvarchar(max)"); + b.Property("CreatedBy") + .HasColumnType("uniqueidentifier"); b.Property("Currency") .IsRequired() @@ -99,11 +98,11 @@ namespace Hutopy.Infrastructure.Migrations b.Property("IsConfirmed") .HasColumnType("bit"); - b.Property("LastModified") + b.Property("LastModifiedAt") .HasColumnType("datetimeoffset"); - b.Property("LastModifiedBy") - .HasColumnType("nvarchar(max)"); + b.Property("LastModifiedBy") + .HasColumnType("uniqueidentifier"); b.Property("Paid") .HasColumnType("bit"); @@ -147,18 +146,67 @@ namespace Hutopy.Infrastructure.Migrations b.ToTable("UserTransactions"); }); - modelBuilder.Entity("Hutopy.Infrastructure.Identity.ApplicationUser", b => + modelBuilder.Entity("Hutopy.Infrastructure.Identity.ApplicationRole", b => { - b.Property("Id") - .HasColumnType("nvarchar(450)"); - - b.Property("AccessFailedCount") - .HasColumnType("int"); + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); b.Property("ConcurrencyStamp") .IsConcurrencyToken() .HasColumnType("nvarchar(max)"); + b.Property("Name") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("NormalizedName") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedName") + .IsUnique() + .HasDatabaseName("RoleNameIndex") + .HasFilter("[NormalizedName] IS NOT NULL"); + + b.ToTable("AspNetRoles", (string)null); + }); + + modelBuilder.Entity("Hutopy.Infrastructure.Identity.ApplicationUser", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("AccessFailedCount") + .HasColumnType("int"); + + b.Property("Address") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("Alias") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("BirthDate") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("City") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("nvarchar(max)"); + + b.Property("Country") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + b.Property("Email") .HasMaxLength(256) .HasColumnType("nvarchar(256)"); @@ -167,12 +215,12 @@ namespace Hutopy.Infrastructure.Migrations .HasColumnType("bit"); b.Property("FirstName") - .IsRequired() - .HasColumnType("nvarchar(max)"); + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); b.Property("LastName") - .IsRequired() - .HasColumnType("nvarchar(max)"); + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); b.Property("LockoutEnabled") .HasColumnType("bit"); @@ -188,6 +236,10 @@ namespace Hutopy.Infrastructure.Migrations .HasMaxLength(256) .HasColumnType("nvarchar(256)"); + b.Property("Occupation") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + b.Property("PasswordHash") .HasColumnType("nvarchar(max)"); @@ -197,6 +249,10 @@ namespace Hutopy.Infrastructure.Migrations b.Property("PhoneNumberConfirmed") .HasColumnType("bit"); + b.Property("PortraitUrl") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + b.Property("SecurityStamp") .HasColumnType("nvarchar(max)"); @@ -220,34 +276,7 @@ namespace Hutopy.Infrastructure.Migrations b.ToTable("AspNetUsers", (string)null); }); - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b => - { - b.Property("Id") - .HasColumnType("nvarchar(450)"); - - b.Property("ConcurrencyStamp") - .IsConcurrencyToken() - .HasColumnType("nvarchar(max)"); - - b.Property("Name") - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.Property("NormalizedName") - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.HasKey("Id"); - - b.HasIndex("NormalizedName") - .IsUnique() - .HasDatabaseName("RoleNameIndex") - .HasFilter("[NormalizedName] IS NOT NULL"); - - b.ToTable("AspNetRoles", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => { b.Property("Id") .ValueGeneratedOnAdd() @@ -261,9 +290,8 @@ namespace Hutopy.Infrastructure.Migrations b.Property("ClaimValue") .HasColumnType("nvarchar(max)"); - b.Property("RoleId") - .IsRequired() - .HasColumnType("nvarchar(450)"); + b.Property("RoleId") + .HasColumnType("uniqueidentifier"); b.HasKey("Id"); @@ -272,7 +300,7 @@ namespace Hutopy.Infrastructure.Migrations b.ToTable("AspNetRoleClaims", (string)null); }); - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => { b.Property("Id") .ValueGeneratedOnAdd() @@ -286,9 +314,8 @@ namespace Hutopy.Infrastructure.Migrations b.Property("ClaimValue") .HasColumnType("nvarchar(max)"); - b.Property("UserId") - .IsRequired() - .HasColumnType("nvarchar(450)"); + b.Property("UserId") + .HasColumnType("uniqueidentifier"); b.HasKey("Id"); @@ -297,7 +324,7 @@ namespace Hutopy.Infrastructure.Migrations b.ToTable("AspNetUserClaims", (string)null); }); - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => { b.Property("LoginProvider") .HasColumnType("nvarchar(450)"); @@ -308,9 +335,8 @@ namespace Hutopy.Infrastructure.Migrations b.Property("ProviderDisplayName") .HasColumnType("nvarchar(max)"); - b.Property("UserId") - .IsRequired() - .HasColumnType("nvarchar(450)"); + b.Property("UserId") + .HasColumnType("uniqueidentifier"); b.HasKey("LoginProvider", "ProviderKey"); @@ -319,13 +345,13 @@ namespace Hutopy.Infrastructure.Migrations b.ToTable("AspNetUserLogins", (string)null); }); - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => { - b.Property("UserId") - .HasColumnType("nvarchar(450)"); + b.Property("UserId") + .HasColumnType("uniqueidentifier"); - b.Property("RoleId") - .HasColumnType("nvarchar(450)"); + b.Property("RoleId") + .HasColumnType("uniqueidentifier"); b.HasKey("UserId", "RoleId"); @@ -334,10 +360,10 @@ namespace Hutopy.Infrastructure.Migrations b.ToTable("AspNetUserRoles", (string)null); }); - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => { - b.Property("UserId") - .HasColumnType("nvarchar(450)"); + b.Property("UserId") + .HasColumnType("uniqueidentifier"); b.Property("LoginProvider") .HasColumnType("nvarchar(450)"); @@ -362,16 +388,16 @@ namespace Hutopy.Infrastructure.Migrations .IsRequired(); }); - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => { - b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) + b.HasOne("Hutopy.Infrastructure.Identity.ApplicationRole", null) .WithMany() .HasForeignKey("RoleId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); }); - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => { b.HasOne("Hutopy.Infrastructure.Identity.ApplicationUser", null) .WithMany() @@ -380,7 +406,7 @@ namespace Hutopy.Infrastructure.Migrations .IsRequired(); }); - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => { b.HasOne("Hutopy.Infrastructure.Identity.ApplicationUser", null) .WithMany() @@ -389,9 +415,9 @@ namespace Hutopy.Infrastructure.Migrations .IsRequired(); }); - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => { - b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) + b.HasOne("Hutopy.Infrastructure.Identity.ApplicationRole", null) .WithMany() .HasForeignKey("RoleId") .OnDelete(DeleteBehavior.Cascade) @@ -404,7 +430,7 @@ namespace Hutopy.Infrastructure.Migrations .IsRequired(); }); - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => { b.HasOne("Hutopy.Infrastructure.Identity.ApplicationUser", null) .WithMany() diff --git a/src/Infrastructure/Migrations/20240418221249_InitialMigration.cs b/src/Infrastructure/Migrations/20240802044736_Initial.cs similarity index 69% rename from src/Infrastructure/Migrations/20240418221249_InitialMigration.cs rename to src/Infrastructure/Migrations/20240802044736_Initial.cs index ae91d8e..5b50f9c 100644 --- a/src/Infrastructure/Migrations/20240418221249_InitialMigration.cs +++ b/src/Infrastructure/Migrations/20240802044736_Initial.cs @@ -6,7 +6,7 @@ using Microsoft.EntityFrameworkCore.Migrations; namespace Hutopy.Infrastructure.Migrations { /// - public partial class InitialMigration : Migration + public partial class Initial : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) @@ -15,7 +15,7 @@ namespace Hutopy.Infrastructure.Migrations name: "AspNetRoles", columns: table => new { - Id = table.Column(type: "nvarchar(450)", nullable: false), + Id = table.Column(type: "uniqueidentifier", nullable: false), Name = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), NormalizedName = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), ConcurrencyStamp = table.Column(type: "nvarchar(max)", nullable: true) @@ -29,9 +29,16 @@ namespace Hutopy.Infrastructure.Migrations name: "AspNetUsers", columns: table => new { - Id = table.Column(type: "nvarchar(450)", nullable: false), - FirstName = table.Column(type: "nvarchar(max)", nullable: false), - LastName = table.Column(type: "nvarchar(max)", nullable: false), + Id = table.Column(type: "uniqueidentifier", nullable: false), + Alias = table.Column(type: "nvarchar(255)", maxLength: 255, nullable: true), + FirstName = table.Column(type: "nvarchar(255)", maxLength: 255, nullable: true), + LastName = table.Column(type: "nvarchar(255)", maxLength: 255, nullable: true), + Occupation = table.Column(type: "nvarchar(255)", maxLength: 255, nullable: true), + BirthDate = table.Column(type: "nvarchar(255)", maxLength: 255, nullable: true), + Country = table.Column(type: "nvarchar(255)", maxLength: 255, nullable: true), + City = table.Column(type: "nvarchar(255)", maxLength: 255, nullable: true), + Address = table.Column(type: "nvarchar(255)", maxLength: 255, nullable: true), + PortraitUrl = table.Column(type: "nvarchar(255)", maxLength: 255, nullable: true), UserName = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), NormalizedUserName = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), Email = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), @@ -63,10 +70,10 @@ namespace Hutopy.Infrastructure.Migrations PhoneNumber = table.Column(type: "nvarchar(max)", nullable: false), SocialNetworkAccount = table.Column(type: "nvarchar(max)", nullable: false), ReasonToJoin = table.Column(type: "nvarchar(max)", nullable: false), - Created = table.Column(type: "datetimeoffset", nullable: false), - CreatedBy = table.Column(type: "nvarchar(max)", nullable: true), - LastModified = table.Column(type: "datetimeoffset", nullable: false), - LastModifiedBy = table.Column(type: "nvarchar(max)", nullable: true) + CreatedAt = table.Column(type: "datetimeoffset", nullable: false), + CreatedBy = table.Column(type: "uniqueidentifier", nullable: true), + LastModifiedAt = table.Column(type: "datetimeoffset", nullable: false), + LastModifiedBy = table.Column(type: "uniqueidentifier", nullable: true) }, constraints: table => { @@ -79,7 +86,7 @@ namespace Hutopy.Infrastructure.Migrations { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), - RoleId = table.Column(type: "nvarchar(450)", nullable: false), + RoleId = table.Column(type: "uniqueidentifier", nullable: false), ClaimType = table.Column(type: "nvarchar(max)", nullable: true), ClaimValue = table.Column(type: "nvarchar(max)", nullable: true) }, @@ -100,7 +107,7 @@ namespace Hutopy.Infrastructure.Migrations { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), - UserId = table.Column(type: "nvarchar(450)", nullable: false), + UserId = table.Column(type: "uniqueidentifier", nullable: false), ClaimType = table.Column(type: "nvarchar(max)", nullable: true), ClaimValue = table.Column(type: "nvarchar(max)", nullable: true) }, @@ -122,7 +129,7 @@ namespace Hutopy.Infrastructure.Migrations LoginProvider = table.Column(type: "nvarchar(450)", nullable: false), ProviderKey = table.Column(type: "nvarchar(450)", nullable: false), ProviderDisplayName = table.Column(type: "nvarchar(max)", nullable: true), - UserId = table.Column(type: "nvarchar(450)", nullable: false) + UserId = table.Column(type: "uniqueidentifier", nullable: false) }, constraints: table => { @@ -139,8 +146,8 @@ namespace Hutopy.Infrastructure.Migrations name: "AspNetUserRoles", columns: table => new { - UserId = table.Column(type: "nvarchar(450)", nullable: false), - RoleId = table.Column(type: "nvarchar(450)", nullable: false) + UserId = table.Column(type: "uniqueidentifier", nullable: false), + RoleId = table.Column(type: "uniqueidentifier", nullable: false) }, constraints: table => { @@ -163,7 +170,7 @@ namespace Hutopy.Infrastructure.Migrations name: "AspNetUserTokens", columns: table => new { - UserId = table.Column(type: "nvarchar(450)", nullable: false), + UserId = table.Column(type: "uniqueidentifier", nullable: false), LoginProvider = table.Column(type: "nvarchar(450)", nullable: false), Name = table.Column(type: "nvarchar(450)", nullable: false), Value = table.Column(type: "nvarchar(max)", nullable: true) @@ -179,6 +186,40 @@ namespace Hutopy.Infrastructure.Migrations onDelete: ReferentialAction.Cascade); }); + migrationBuilder.CreateTable( + name: "UserTransactions", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + Amount = table.Column(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false), + Currency = table.Column(type: "nvarchar(max)", nullable: false), + TipMessage = table.Column(type: "nvarchar(max)", nullable: false), + ApplicationUserId = table.Column(type: "uniqueidentifier", nullable: false), + IsConfirmed = table.Column(type: "bit", nullable: false), + StripeEventId = table.Column(type: "nvarchar(max)", nullable: false), + StripeChargeId = table.Column(type: "nvarchar(max)", nullable: false), + StripePaymentIntent = table.Column(type: "nvarchar(max)", nullable: false), + StripePaymentMethod = table.Column(type: "nvarchar(max)", nullable: false), + StripeReceiptUrl = table.Column(type: "nvarchar(max)", nullable: false), + StripeBillingDetailEmail = table.Column(type: "nvarchar(max)", nullable: false), + StripeBillingDetailName = table.Column(type: "nvarchar(max)", nullable: false), + Paid = table.Column(type: "bit", nullable: false), + CreatedAt = table.Column(type: "datetimeoffset", nullable: false), + CreatedBy = table.Column(type: "uniqueidentifier", nullable: true), + LastModifiedAt = table.Column(type: "datetimeoffset", nullable: false), + LastModifiedBy = table.Column(type: "uniqueidentifier", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_UserTransactions", x => x.Id); + table.ForeignKey( + name: "FK_UserTransactions_AspNetUsers_ApplicationUserId", + column: x => x.ApplicationUserId, + principalTable: "AspNetUsers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + migrationBuilder.CreateIndex( name: "IX_AspNetRoleClaims_RoleId", table: "AspNetRoleClaims", @@ -217,6 +258,11 @@ namespace Hutopy.Infrastructure.Migrations column: "NormalizedUserName", unique: true, filter: "[NormalizedUserName] IS NOT NULL"); + + migrationBuilder.CreateIndex( + name: "IX_UserTransactions_ApplicationUserId", + table: "UserTransactions", + column: "ApplicationUserId"); } /// @@ -240,6 +286,9 @@ namespace Hutopy.Infrastructure.Migrations migrationBuilder.DropTable( name: "FutureCreators"); + migrationBuilder.DropTable( + name: "UserTransactions"); + migrationBuilder.DropTable( name: "AspNetRoles"); diff --git a/src/Infrastructure/Migrations/ApplicationDbContextModelSnapshot.cs b/src/Infrastructure/Migrations/ApplicationDbContextModelSnapshot.cs index 8b4b9ec..7e0e9ed 100644 --- a/src/Infrastructure/Migrations/ApplicationDbContextModelSnapshot.cs +++ b/src/Infrastructure/Migrations/ApplicationDbContextModelSnapshot.cs @@ -28,11 +28,11 @@ namespace Hutopy.Infrastructure.Migrations .ValueGeneratedOnAdd() .HasColumnType("uniqueidentifier"); - b.Property("Created") + b.Property("CreatedAt") .HasColumnType("datetimeoffset"); - b.Property("CreatedBy") - .HasColumnType("nvarchar(max)"); + b.Property("CreatedBy") + .HasColumnType("uniqueidentifier"); b.Property("EmailAddress") .IsRequired() @@ -42,11 +42,11 @@ namespace Hutopy.Infrastructure.Migrations .IsRequired() .HasColumnType("nvarchar(max)"); - b.Property("LastModified") + b.Property("LastModifiedAt") .HasColumnType("datetimeoffset"); - b.Property("LastModifiedBy") - .HasColumnType("nvarchar(max)"); + b.Property("LastModifiedBy") + .HasColumnType("uniqueidentifier"); b.Property("LastName") .IsRequired() @@ -66,7 +66,7 @@ namespace Hutopy.Infrastructure.Migrations b.HasKey("Id"); - b.ToTable("FutureCreators", (string)null); + b.ToTable("FutureCreators"); }); modelBuilder.Entity("Hutopy.Domain.Entities.UserTransaction", b => @@ -79,15 +79,14 @@ namespace Hutopy.Infrastructure.Migrations .HasPrecision(18, 2) .HasColumnType("decimal(18,2)"); - b.Property("ApplicationUserId") - .IsRequired() - .HasColumnType("nvarchar(450)"); + b.Property("ApplicationUserId") + .HasColumnType("uniqueidentifier"); - b.Property("Created") + b.Property("CreatedAt") .HasColumnType("datetimeoffset"); - b.Property("CreatedBy") - .HasColumnType("nvarchar(max)"); + b.Property("CreatedBy") + .HasColumnType("uniqueidentifier"); b.Property("Currency") .IsRequired() @@ -96,11 +95,11 @@ namespace Hutopy.Infrastructure.Migrations b.Property("IsConfirmed") .HasColumnType("bit"); - b.Property("LastModified") + b.Property("LastModifiedAt") .HasColumnType("datetimeoffset"); - b.Property("LastModifiedBy") - .HasColumnType("nvarchar(max)"); + b.Property("LastModifiedBy") + .HasColumnType("uniqueidentifier"); b.Property("Paid") .HasColumnType("bit"); @@ -141,50 +140,69 @@ namespace Hutopy.Infrastructure.Migrations b.HasIndex("ApplicationUserId"); - b.ToTable("UserTransactions", (string)null); + b.ToTable("UserTransactions"); + }); + + modelBuilder.Entity("Hutopy.Infrastructure.Identity.ApplicationRole", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("NormalizedName") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedName") + .IsUnique() + .HasDatabaseName("RoleNameIndex") + .HasFilter("[NormalizedName] IS NOT NULL"); + + b.ToTable("AspNetRoles", (string)null); }); modelBuilder.Entity("Hutopy.Infrastructure.Identity.ApplicationUser", b => { - b.Property("Id") - .HasColumnType("nvarchar(450)"); - - b.Property("About") - .IsRequired() - .HasColumnType("nvarchar(max)"); + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); b.Property("AccessFailedCount") .HasColumnType("int"); b.Property("Address") - .IsRequired() - .HasColumnType("nvarchar(max)"); + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); b.Property("Alias") - .HasColumnType("nvarchar(max)"); + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); b.Property("BirthDate") - .IsRequired() - .HasColumnType("nvarchar(max)"); + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); b.Property("City") - .IsRequired() - .HasColumnType("nvarchar(max)"); + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); b.Property("ConcurrencyStamp") .IsConcurrencyToken() .HasColumnType("nvarchar(max)"); b.Property("Country") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("CreatorAlias") - .HasColumnType("nvarchar(max)"); - - b.Property("Description") - .IsRequired() - .HasColumnType("nvarchar(max)"); + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); b.Property("Email") .HasMaxLength(256) @@ -194,12 +212,12 @@ namespace Hutopy.Infrastructure.Migrations .HasColumnType("bit"); b.Property("FirstName") - .IsRequired() - .HasColumnType("nvarchar(max)"); + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); b.Property("LastName") - .IsRequired() - .HasColumnType("nvarchar(max)"); + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); b.Property("LockoutEnabled") .HasColumnType("bit"); @@ -216,8 +234,8 @@ namespace Hutopy.Infrastructure.Migrations .HasColumnType("nvarchar(256)"); b.Property("Occupation") - .IsRequired() - .HasColumnType("nvarchar(max)"); + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); b.Property("PasswordHash") .HasColumnType("nvarchar(max)"); @@ -228,6 +246,10 @@ namespace Hutopy.Infrastructure.Migrations b.Property("PhoneNumberConfirmed") .HasColumnType("bit"); + b.Property("PortraitUrl") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + b.Property("SecurityStamp") .HasColumnType("nvarchar(max)"); @@ -251,34 +273,7 @@ namespace Hutopy.Infrastructure.Migrations b.ToTable("AspNetUsers", (string)null); }); - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b => - { - b.Property("Id") - .HasColumnType("nvarchar(450)"); - - b.Property("ConcurrencyStamp") - .IsConcurrencyToken() - .HasColumnType("nvarchar(max)"); - - b.Property("Name") - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.Property("NormalizedName") - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.HasKey("Id"); - - b.HasIndex("NormalizedName") - .IsUnique() - .HasDatabaseName("RoleNameIndex") - .HasFilter("[NormalizedName] IS NOT NULL"); - - b.ToTable("AspNetRoles", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => { b.Property("Id") .ValueGeneratedOnAdd() @@ -292,9 +287,8 @@ namespace Hutopy.Infrastructure.Migrations b.Property("ClaimValue") .HasColumnType("nvarchar(max)"); - b.Property("RoleId") - .IsRequired() - .HasColumnType("nvarchar(450)"); + b.Property("RoleId") + .HasColumnType("uniqueidentifier"); b.HasKey("Id"); @@ -303,7 +297,7 @@ namespace Hutopy.Infrastructure.Migrations b.ToTable("AspNetRoleClaims", (string)null); }); - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => { b.Property("Id") .ValueGeneratedOnAdd() @@ -317,9 +311,8 @@ namespace Hutopy.Infrastructure.Migrations b.Property("ClaimValue") .HasColumnType("nvarchar(max)"); - b.Property("UserId") - .IsRequired() - .HasColumnType("nvarchar(450)"); + b.Property("UserId") + .HasColumnType("uniqueidentifier"); b.HasKey("Id"); @@ -328,7 +321,7 @@ namespace Hutopy.Infrastructure.Migrations b.ToTable("AspNetUserClaims", (string)null); }); - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => { b.Property("LoginProvider") .HasColumnType("nvarchar(450)"); @@ -339,9 +332,8 @@ namespace Hutopy.Infrastructure.Migrations b.Property("ProviderDisplayName") .HasColumnType("nvarchar(max)"); - b.Property("UserId") - .IsRequired() - .HasColumnType("nvarchar(450)"); + b.Property("UserId") + .HasColumnType("uniqueidentifier"); b.HasKey("LoginProvider", "ProviderKey"); @@ -350,13 +342,13 @@ namespace Hutopy.Infrastructure.Migrations b.ToTable("AspNetUserLogins", (string)null); }); - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => { - b.Property("UserId") - .HasColumnType("nvarchar(450)"); + b.Property("UserId") + .HasColumnType("uniqueidentifier"); - b.Property("RoleId") - .HasColumnType("nvarchar(450)"); + b.Property("RoleId") + .HasColumnType("uniqueidentifier"); b.HasKey("UserId", "RoleId"); @@ -365,10 +357,10 @@ namespace Hutopy.Infrastructure.Migrations b.ToTable("AspNetUserRoles", (string)null); }); - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => { - b.Property("UserId") - .HasColumnType("nvarchar(450)"); + b.Property("UserId") + .HasColumnType("uniqueidentifier"); b.Property("LoginProvider") .HasColumnType("nvarchar(450)"); @@ -393,127 +385,16 @@ namespace Hutopy.Infrastructure.Migrations .IsRequired(); }); - modelBuilder.Entity("Hutopy.Infrastructure.Identity.ApplicationUser", b => + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => { - b.OwnsOne("Hutopy.Infrastructure.Identity.ApplicationUser.ProfileColors#Hutopy.Infrastructure.Identity.OwnedEntities.ProfileColors", "ProfileColors", b1 => - { - b1.Property("ApplicationUserId") - .HasColumnType("nvarchar(450)"); - - b1.Property("Accent") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("BannerBottom") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("BannerTop") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("Menu") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.HasKey("ApplicationUserId"); - - b1.ToTable("ApplicationUser_ProfileColors", (string)null); - - b1.WithOwner() - .HasForeignKey("ApplicationUserId"); - }); - - b.OwnsOne("Hutopy.Infrastructure.Identity.ApplicationUser.SocialNetworks#Hutopy.Infrastructure.Identity.OwnedEntities.SocialNetworks", "SocialNetworks", b1 => - { - b1.Property("ApplicationUserId") - .HasColumnType("nvarchar(450)"); - - b1.Property("FacebookUrl") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("InstagramUrl") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("LinkedInUrl") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("RedditUrl") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("TikTokUrl") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("XUrl") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("YourWebsiteUrl") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("YoutubeUrl") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.HasKey("ApplicationUserId"); - - b1.ToTable("ApplicationUser_SocialNetworks", (string)null); - - b1.WithOwner() - .HasForeignKey("ApplicationUserId"); - }); - - b.OwnsOne("Hutopy.Infrastructure.Identity.ApplicationUser.StoredDataUrls#Hutopy.Infrastructure.Identity.OwnedEntities.StoredDataUrls", "StoredDataUrls", b1 => - { - b1.Property("ApplicationUserId") - .HasColumnType("nvarchar(450)"); - - b1.Property("BannerPictureUrl") - .HasMaxLength(255) - .HasColumnType("nvarchar(255)"); - - b1.Property("ProfilePictureUrl") - .HasMaxLength(255) - .HasColumnType("nvarchar(255)"); - - b1.Property("WebsiteIconUrl") - .HasMaxLength(255) - .HasColumnType("nvarchar(255)"); - - b1.HasKey("ApplicationUserId"); - - b1.ToTable("ApplicationUser_StoredDataUrls", (string)null); - - b1.WithOwner() - .HasForeignKey("ApplicationUserId"); - }); - - b.Navigation("ProfileColors") - .IsRequired(); - - b.Navigation("SocialNetworks") - .IsRequired(); - - b.Navigation("StoredDataUrls") - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => - { - b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) + b.HasOne("Hutopy.Infrastructure.Identity.ApplicationRole", null) .WithMany() .HasForeignKey("RoleId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); }); - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => { b.HasOne("Hutopy.Infrastructure.Identity.ApplicationUser", null) .WithMany() @@ -522,7 +403,7 @@ namespace Hutopy.Infrastructure.Migrations .IsRequired(); }); - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => { b.HasOne("Hutopy.Infrastructure.Identity.ApplicationUser", null) .WithMany() @@ -531,9 +412,9 @@ namespace Hutopy.Infrastructure.Migrations .IsRequired(); }); - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => { - b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) + b.HasOne("Hutopy.Infrastructure.Identity.ApplicationRole", null) .WithMany() .HasForeignKey("RoleId") .OnDelete(DeleteBehavior.Cascade) @@ -546,7 +427,7 @@ namespace Hutopy.Infrastructure.Migrations .IsRequired(); }); - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => { b.HasOne("Hutopy.Infrastructure.Identity.ApplicationUser", null) .WithMany() diff --git a/src/Infrastructure/Stripe/StripeService.cs b/src/Infrastructure/Stripe/StripeService.cs index 3f4e366..7b78fff 100644 --- a/src/Infrastructure/Stripe/StripeService.cs +++ b/src/Infrastructure/Stripe/StripeService.cs @@ -1,6 +1,3 @@ -using System; -using System.Collections.Generic; -using System.Threading.Tasks; using Stripe; using Stripe.Checkout; using Hutopy.Application.Common.Interfaces; diff --git a/src/Infrastructure/Utils/GenerateJwtToken.cs b/src/Infrastructure/Utils/GenerateJwtToken.cs index 7992e14..d2120b8 100644 --- a/src/Infrastructure/Utils/GenerateJwtToken.cs +++ b/src/Infrastructure/Utils/GenerateJwtToken.cs @@ -17,7 +17,7 @@ public static class JwtTokenHelper string? alias, string firstname, string lastname, - string? profilePictureUrl) + string? portraitUrl) { var securityKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(key)); var credentials = new SigningCredentials(securityKey, SecurityAlgorithms.HmacSha256); @@ -36,9 +36,9 @@ public static class JwtTokenHelper claims.Add(new(KnownClaims.Alias, alias)); } - if (profilePictureUrl is not null) + if (portraitUrl is not null) { - claims.Add(new(KnownClaims.PortraitUrl, profilePictureUrl)); + claims.Add(new(KnownClaims.PortraitUrl, portraitUrl)); } var token = new JwtSecurityToken( diff --git a/src/Infrastructure/Utils/KnownClaims.cs b/src/Infrastructure/Utils/KnownClaims.cs index 96b1de9..21d44e2 100644 --- a/src/Infrastructure/Utils/KnownClaims.cs +++ b/src/Infrastructure/Utils/KnownClaims.cs @@ -2,6 +2,6 @@ namespace Hutopy.Infrastructure.Utils; public static class KnownClaims { - public const string Alias = nameof(Alias); - public const string PortraitUrl = nameof(PortraitUrl); + public const string Alias = "alias"; + public const string PortraitUrl = "portraitUrl"; } diff --git a/src/Web/Controllers/GoogleController.cs b/src/Web/Controllers/GoogleController.cs index f45006a..1030f43 100644 --- a/src/Web/Controllers/GoogleController.cs +++ b/src/Web/Controllers/GoogleController.cs @@ -72,12 +72,12 @@ public class GoogleController( jwtOptions.Value.Issuer, jwtOptions.Value.Audience, jwtOptions.Value.Key, - user.Id, + user.Id.ToString(), user.Email, user.Alias, user.FirstName, user.LastName, - user.StoredDataUrls.ProfilePictureUrl); + user.PortraitUrl); return Ok(new { accessToken = token, email }); } diff --git a/src/Web/DependencyInjection.cs b/src/Web/DependencyInjection.cs index 2a76f33..e1ca536 100644 --- a/src/Web/DependencyInjection.cs +++ b/src/Web/DependencyInjection.cs @@ -9,8 +9,6 @@ using Microsoft.AspNetCore.Authentication.Google; using Microsoft.AspNetCore.Authentication.JwtBearer; using Microsoft.AspNetCore.Mvc; using Microsoft.IdentityModel.Tokens; -using NSwag; -using NSwag.Generation.Processors.Security; namespace Hutopy.Web; diff --git a/src/Web/Endpoints/GetMyUser.cs b/src/Web/Endpoints/GetMyUser.cs index 444cbe9..4d88e2b 100644 --- a/src/Web/Endpoints/GetMyUser.cs +++ b/src/Web/Endpoints/GetMyUser.cs @@ -1,5 +1,4 @@ -using Hutopy.Application.Users.Queries; -using Hutopy.Application.Users.Queries.GetCurrentUser; +using Hutopy.Application.Users.Queries.GetCurrentUser; namespace Hutopy.Web.Endpoints; diff --git a/src/Web/Endpoints/UpdateMyUser.cs b/src/Web/Endpoints/UpdateMyUser.cs index 7399116..3416dfd 100644 --- a/src/Web/Endpoints/UpdateMyUser.cs +++ b/src/Web/Endpoints/UpdateMyUser.cs @@ -9,31 +9,19 @@ public class UpdateMyUser : EndpointGroupBase app.MapGroup(this) .RequireAuthorization() .MapPost(UpdateCurrentUserProfilePicture, "/profile-picture") - .MapPost(UpdateCurrentUserBannerPicture, "/banner-picture") - .MapPost(UpdateCurrentUserWebsiteIcon, "/website-icon") .MapPatch("/profile", UpdateCurrentUser); } - + private static async Task UpdateCurrentUser(ISender sender, UpdateCurrentUserCommand command) { return await sender.Send(command); } - - private static async Task UpdateCurrentUserProfilePicture(ISender sender, MemoryStream stream, string url = "") + + private static async Task UpdateCurrentUserProfilePicture( + ISender sender, + IFormFile formFile) { - var command = new UploadProfilePictureCommand { ProfilePicture = stream, ProfilePictureUrl = url}; - return await sender.Send(command); - } - - private static async Task UpdateCurrentUserBannerPicture(ISender sender, MemoryStream stream, string url = "") - { - var command = new UploadBannerPictureCommand { BannerPicture = stream, BannerPictureUrl = url}; - return await sender.Send(command); - } - - private static async Task UpdateCurrentUserWebsiteIcon(ISender sender, MemoryStream stream, string url = "") - { - var command = new UploadWebsiteIconCommand { WebsiteIcon = stream, WebsitePictureUrl = url}; + var command = new UploadProfilePictureCommand { File = formFile }; return await sender.Send(command); } } diff --git a/src/Web/Endpoints/Users.cs b/src/Web/Endpoints/Users.cs index bbdeb4c..4757789 100644 --- a/src/Web/Endpoints/Users.cs +++ b/src/Web/Endpoints/Users.cs @@ -10,7 +10,8 @@ public class Users : EndpointGroupBase app.MapGroup(this) .MapPost(CreateUser) .MapPost(Login, "/login") - .MapGet(GetUser); + .MapGet(GetUserById, "/id") + .MapGet(GetUserByUserName, "/user-name"); } private static async Task CreateUser(ISender sender, CreateUserCommand command) @@ -18,7 +19,14 @@ public class Users : EndpointGroupBase return await sender.Send(command); } - private static async Task GetUser(ISender sender, [AsParameters] GetUserQuery query) + private static async Task GetUserById(ISender sender, + [AsParameters] GetUserByIdQuery query) + { + return await sender.Send(query); + } + + private static async Task GetUserByUserName(ISender sender, + [AsParameters] GetUserByUserNameQuery query) { return await sender.Send(query); } diff --git a/src/Web/Features/Contents/Data/ContentDbContext.cs b/src/Web/Features/Contents/Data/ContentDbContext.cs index 9f6b739..1215d7f 100644 --- a/src/Web/Features/Contents/Data/ContentDbContext.cs +++ b/src/Web/Features/Contents/Data/ContentDbContext.cs @@ -7,17 +7,50 @@ public class ContentDbContext( : DbContext(options) { public const string SchemaName = "Content"; - + protected override void OnModelCreating(ModelBuilder modelBuilder) { modelBuilder.HasDefaultSchema("Content"); - + modelBuilder .Entity() .Property(c => c.CreatedAt) .ValueGeneratedOnAdd() .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + modelBuilder + .Entity() + .OwnsOne(x => x.About); + + modelBuilder + .Entity() + .OwnsOne(x => x.SocialNetworks); + + modelBuilder + .Entity() + .OwnsOne(x => x.ProfileColors); + + modelBuilder + .Entity() + .OwnsOne(x => x.StoredDataUrls); } - public DbSet Contents { get; set; } + public DbSet Contents { get; init; } = null!; + public DbSet Creators { get; init; } = null!; + + + public async Task FindByCreatorAliasAsync( + string creatorAlias, + CancellationToken cancellationToken = default) + { + ArgumentException.ThrowIfNullOrEmpty(creatorAlias); + + var user = await Creators.SingleOrDefaultAsync(creator => + EF.Functions.Like( + creatorAlias, + creator.Name), + cancellationToken: cancellationToken); + + return user; + } } diff --git a/src/Web/Features/Contents/Data/Creator.cs b/src/Web/Features/Contents/Data/Creator.cs new file mode 100644 index 0000000..85a835b --- /dev/null +++ b/src/Web/Features/Contents/Data/Creator.cs @@ -0,0 +1,48 @@ +using System.ComponentModel.DataAnnotations; + +namespace Hutopy.Web.Features.Contents.Data; + +public class Creator +{ + public Guid Id { get; set; } + public Guid CreatedBy { get; init; } + public DateTimeOffset CreatedAt { get; init; } + [MaxLength(255)] public string Name { get; set; } = null!; + + public About About { get; set; } = new(); + public SocialNetworks SocialNetworks { get; set; } = new(); + public ProfileColors ProfileColors { get; set; } = new(); + public StoredDataUrls StoredDataUrls { get; set; } = new(); +} + +public class About +{ + [MaxLength(255)] public string? Title { get; set; } + [MaxLength(255)] public string? Description { get; set; } +} + +public class ProfileColors +{ + [MaxLength(9)] public string? BannerTop { get; set; } + [MaxLength(9)] public string? BannerBottom { get; set; } + [MaxLength(9)] public string? Accent { get; set; } + [MaxLength(9)] public string? Menu { get; set; } +} + +public class SocialNetworks +{ + [MaxLength(255)] public string? FacebookUrl { get; set; } + [MaxLength(255)] public string? InstagramUrl { get; set; } + [MaxLength(255)] public string? XUrl { get; set; } + [MaxLength(255)] public string? LinkedInUrl { get; set; } + [MaxLength(255)] public string? TikTokUrl { get; set; } + [MaxLength(255)] public string? YoutubeUrl { get; set; } + [MaxLength(255)] public string? RedditUrl { get; set; } + [MaxLength(255)] public string? WebsiteUrl { get; set; } +} + +public class StoredDataUrls +{ + [MaxLength(255)] public string? BannerPictureUrl { get; set; } + [MaxLength(255)] public string? ProfilePictureUrl { get; set; } +} diff --git a/src/Web/Features/Contents/Handlers/ChangeBanner.cs b/src/Web/Features/Contents/Handlers/ChangeBanner.cs new file mode 100644 index 0000000..8601ff4 --- /dev/null +++ b/src/Web/Features/Contents/Handlers/ChangeBanner.cs @@ -0,0 +1,49 @@ +using FastEndpoints; +using Hutopy.Application.AzureBlobStorage.Constants; +using Hutopy.Application.Common.Interfaces; +using Hutopy.Application.Utils; +using Hutopy.Web.Features.Contents.Data; +using Microsoft.EntityFrameworkCore; + +namespace Hutopy.Web.Features.Contents.Handlers; + +public record ChangeBannerRequest( + Guid CreatorId, + IFormFile File); + +public class ChangeBannerHandler( + IHttpContextAccessor contextAccessor, + ContentDbContext context, + IAzureBlobStorageService azureBlobStorageService) + : Endpoint +{ + public override void Configure() + { + Post("/api/creators/{CreatorId}/banner"); + Options(o => o.WithTags("Contents")); + AllowFileUploads(); + } + + public override async Task HandleAsync(ChangeBannerRequest request, CancellationToken ct) + { + var creator = await context + .Creators + .Include(c => c.StoredDataUrls) + .SingleAsync( + c => c.Id == request.CreatorId, + cancellationToken: ct); + + var contentType = contextAccessor.EnsureContentType(); + + var blobUrl = await azureBlobStorageService.UploadFileAsync( + ContainerNames.Users, + $"{request.CreatorId}/{SubDirectoryNames.Profile}/{CommonFileNames.BannerPicture}", + request.File.OpenReadStream(), + contentType, + ct); + + await context.SaveChangesAsync(ct); + + await SendOkAsync(blobUrl, ct); + } +} diff --git a/src/Web/Features/Contents/Handlers/ChangeColors.cs b/src/Web/Features/Contents/Handlers/ChangeColors.cs new file mode 100644 index 0000000..76a003f --- /dev/null +++ b/src/Web/Features/Contents/Handlers/ChangeColors.cs @@ -0,0 +1,71 @@ +using FastEndpoints; +using FluentValidation; +using Hutopy.Web.Features.Contents.Data; +using Microsoft.EntityFrameworkCore; + +namespace Hutopy.Web.Features.Contents.Handlers; + +public record ChangeColorsRequest( + Guid CreatorId, + string? BannerTop, + string? BannerBottom, + string? Accent, + string? Menu); + +public sealed class ChangeColorsRequestValidator + : Validator +{ + public ChangeColorsRequestValidator() + { + RuleFor(x => x.BannerTop) + .MinimumLength(4).WithMessage("The minimum value should be in the format #444") + .MinimumLength(9).WithMessage("The maximum value should be in the format #11223344") + .Must(x => x.StartsWith('#')).WithMessage("The format should be a valid html color and start with #"); + + RuleFor(x => x.BannerBottom) + .MinimumLength(4).WithMessage("The minimum value should be in the format #444") + .MinimumLength(9).WithMessage("The maximum value should be in the format #11223344") + .Must(x => x.StartsWith('#')).WithMessage("The format should be a valid html color and start with #"); + + RuleFor(x => x.Accent) + .MinimumLength(4).WithMessage("The minimum value should be in the format #444") + .MinimumLength(9).WithMessage("The maximum value should be in the format #11223344") + .Must(x => x.StartsWith('#')).WithMessage("The format should be a valid html color and start with #"); + + RuleFor(x => x.Menu) + .MinimumLength(4).WithMessage("The minimum value should be in the format #444") + .MinimumLength(9).WithMessage("The maximum value should be in the format #11223344") + .Must(x => x.StartsWith('#')).WithMessage("The format should be a valid html color and start with #"); + } +} + +public class ChangeColorsHandler( + ContentDbContext context) + : Endpoint +{ + public override void Configure() + { + Post("/api/creators/{CreatorId}/colors"); + Options(o => o.WithTags("Contents")); + AllowFileUploads(); + } + + public override async Task HandleAsync(ChangeColorsRequest request, CancellationToken ct) + { + var creator = await context + .Creators + .Include(c => c.ProfileColors) + .SingleAsync( + c => c.Id == request.CreatorId, + cancellationToken: ct); + + creator.ProfileColors.BannerTop = request.BannerTop; + creator.ProfileColors.BannerBottom = request.BannerBottom; + creator.ProfileColors.Accent = request.Accent; + creator.ProfileColors.Menu = request.Menu; + + await context.SaveChangesAsync(ct); + + await SendOkAsync(ct); + } +} diff --git a/src/Web/Features/Contents/Handlers/CreateContent.cs b/src/Web/Features/Contents/Handlers/CreateContent.cs index 9f7c94a..836dbe1 100644 --- a/src/Web/Features/Contents/Handlers/CreateContent.cs +++ b/src/Web/Features/Contents/Handlers/CreateContent.cs @@ -53,6 +53,7 @@ public sealed class PostContent( PostContentRequest req, CancellationToken ct) { + var urls = new ConcurrentBag(); await Parallel.ForEachAsync( @@ -98,14 +99,11 @@ public sealed class PostContent( IFormFile file, CancellationToken ct = default) { - var memoryStream = new MemoryStream(); - await file.CopyToAsync(memoryStream, ct); - // TODO: I would like us to use ContainerNames.Creators but it seems we are missing configurations @jbourdon var url = await blobStorage.UploadFileAsync( ContainerNames.Users, $"{creatorId}/{SubDirectoryNames.Contents}/{contentId}/{file.FileName}", - memoryStream, + file.OpenReadStream(), file.ContentType, ct: ct); diff --git a/src/Web/Features/Contents/Handlers/CreateCreator.cs b/src/Web/Features/Contents/Handlers/CreateCreator.cs new file mode 100644 index 0000000..f68e96b --- /dev/null +++ b/src/Web/Features/Contents/Handlers/CreateCreator.cs @@ -0,0 +1,53 @@ +using FastEndpoints; +using FluentValidation; +using Hutopy.Web.Common; +using Hutopy.Web.Features.Contents.Data; + +namespace Hutopy.Web.Features.Contents.Handlers; + +public record CreateCreatorRequest( + Guid CreatorId, + string Name); + +public sealed class CreateCreatorRequestValidator : Validator +{ + public CreateCreatorRequestValidator() + { + RuleFor(r => r.CreatorId) + .NotNull().WithMessage("You should specify the CreatorId") + .NotEmpty().WithMessage("You should specify a valid/not empty CreatorId"); + + RuleFor(r => r.Name) + .NotNull().WithMessage("You should specify the Name") + .NotEmpty().WithMessage("You should specify a valid/not empty Name"); + } +} + +public sealed class CreateCreatorHandler( + ContentDbContext context) + : Endpoint +{ + public override void Configure() + { + Post("/api/creators"); + Options(o => o.WithTags("Contents")); + } + + public override async Task HandleAsync( + CreateCreatorRequest req, + CancellationToken ct) + { + await context.Creators.AddAsync( + new() + { + Id = req.CreatorId, + CreatedBy = User.GetUserId(), + Name = req.Name + }, + ct); + + await context.SaveChangesAsync(ct); + + await SendOkAsync(ct); + } +} diff --git a/src/Web/Features/Contents/Handlers/GetCreatorByAlias.cs b/src/Web/Features/Contents/Handlers/GetCreatorByAlias.cs index d5277e2..6204558 100644 --- a/src/Web/Features/Contents/Handlers/GetCreatorByAlias.cs +++ b/src/Web/Features/Contents/Handlers/GetCreatorByAlias.cs @@ -1,13 +1,13 @@ using FastEndpoints; using FluentValidation; -using Hutopy.Application.Common.Interfaces; -using Hutopy.Application.Common.Models; +using Hutopy.Web.Features.Contents.Data; +using Microsoft.EntityFrameworkCore; namespace Hutopy.Web.Features.Contents.Handlers; public sealed class GetCreatorByAliasRequest { - public string CreatorAlias { get; init; } + public required string Name { get; set; } } public sealed class GetCreatorByAliasRequestValidator @@ -15,20 +15,20 @@ public sealed class GetCreatorByAliasRequestValidator { public GetCreatorByAliasRequestValidator() { - RuleFor(r => r.CreatorAlias) - .NotNull().WithMessage("You should specify the CreatorAlias") - .NotEmpty().WithMessage("You should specify a valid/not empty CreatorAlias"); + RuleFor(r => r.Name) + .NotNull().WithMessage("You should specify the Name") + .NotEmpty().WithMessage("You should specify a valid/not empty Name"); } } -public class GetCreatorByAlias( - IIdentityService identityService) - : Endpoint +public class GetCreatorByAliasHandler( + ContentDbContext context) + : Endpoint { public override void Configure() { + Get("/api/creators/@{Name}"); Options((o => o.WithTags("Creators"))); - Get("/api/creators/@{CreatorAlias}"); AllowAnonymous(); } @@ -36,10 +36,13 @@ public class GetCreatorByAlias( GetCreatorByAliasRequest req, CancellationToken ct) { - var user = await identityService.FindUserByCreatorAliasAsync( - req.CreatorAlias, - ct); + var creator = await context + .Creators + .SingleOrDefaultAsync( + c => EF.Functions.Like(c.Name, req.Name), + cancellationToken: ct); - await SendAsync(user, cancellation: ct); + if (creator is null) await SendNotFoundAsync(ct); + else await SendAsync(creator, cancellation: ct); } } diff --git a/src/Web/Features/Contents/Handlers/GetCreatorById.cs b/src/Web/Features/Contents/Handlers/GetCreatorById.cs new file mode 100644 index 0000000..a5ed6ad --- /dev/null +++ b/src/Web/Features/Contents/Handlers/GetCreatorById.cs @@ -0,0 +1,47 @@ +using FastEndpoints; +using FluentValidation; +using Hutopy.Web.Features.Contents.Data; + +namespace Hutopy.Web.Features.Contents.Handlers; + +public sealed class GetCreatorByIdRequest +{ + public required Guid CreatorId { get; set; } +} + +public sealed class GetCreatorByIdRequestValidator + : Validator +{ + public GetCreatorByIdRequestValidator() + { + RuleFor(r => r.CreatorId) + .NotNull().WithMessage("You should specify the CreatorId") + .NotEmpty().WithMessage("You should specify a valid/not empty CreatorId"); + } +} + +public class GetCreatorByIdHandler( + ContentDbContext context) + : Endpoint +{ + public override void Configure() + { + Get("/api/creators/{CreatorId}"); + Options((o => o.WithTags("Creators"))); + AllowAnonymous(); + } + + public override async Task HandleAsync( + GetCreatorByIdRequest req, + CancellationToken ct) + { + var creator = await context + .Creators + .FindAsync( + [req.CreatorId], + cancellationToken: ct); + + if (creator is null) await SendNotFoundAsync(ct); + else await SendAsync(creator, cancellation: ct); + } +} diff --git a/src/Web/Features/Contents/Migrations/20240718034516_Initial.Designer.cs b/src/Web/Features/Contents/Migrations/20240718034516_Initial.Designer.cs deleted file mode 100644 index 4ea464a..0000000 --- a/src/Web/Features/Contents/Migrations/20240718034516_Initial.Designer.cs +++ /dev/null @@ -1,59 +0,0 @@ -// -using System; -using Hutopy.Web.Features.Contents.Data; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; - -#nullable disable - -namespace Hutopy.Web.Contents.Migrations -{ - [DbContext(typeof(ContentDbContext))] - [Migration("20240718034516_Initial")] - partial class Initial - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasDefaultSchema("Content") - .HasAnnotation("ProductVersion", "8.0.4") - .HasAnnotation("Relational:MaxIdentifierLength", 63); - - NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); - - modelBuilder.Entity("Hutopy.Web.Contents.Data.Content", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property("CreatedAt") - .ValueGeneratedOnAdd() - .HasColumnType("timestamp with time zone") - .HasDefaultValueSql("CURRENT_TIMESTAMP"); - - b.Property("CreatedBy") - .HasColumnType("uuid"); - - b.Property("Description") - .HasColumnType("text"); - - b.Property("Title") - .HasColumnType("text"); - - b.Property("Uri") - .HasColumnType("text"); - - b.HasKey("Id"); - - b.ToTable("Contents", "Content"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/Web/Features/Contents/Migrations/20240718034516_Initial.cs b/src/Web/Features/Contents/Migrations/20240718034516_Initial.cs deleted file mode 100644 index d2ed5d8..0000000 --- a/src/Web/Features/Contents/Migrations/20240718034516_Initial.cs +++ /dev/null @@ -1,43 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Hutopy.Web.Contents.Migrations -{ - /// - public partial class Initial : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.EnsureSchema( - name: "Content"); - - migrationBuilder.CreateTable( - name: "Contents", - schema: "Content", - columns: table => new - { - Id = table.Column(type: "uuid", nullable: false), - CreatedBy = table.Column(type: "uuid", nullable: false), - CreatedAt = table.Column(type: "timestamp with time zone", nullable: false, defaultValueSql: "CURRENT_TIMESTAMP"), - Title = table.Column(type: "text", nullable: true), - Description = table.Column(type: "text", nullable: true), - Uri = table.Column(type: "text", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_Contents", x => x.Id); - }); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "Contents", - schema: "Content"); - } - } -} diff --git a/src/Web/Features/Contents/Migrations/20240725022229_AddMultipleMediaUrlsToContent.Designer.cs b/src/Web/Features/Contents/Migrations/20240725022229_AddMultipleMediaUrlsToContent.Designer.cs deleted file mode 100644 index 6971bc3..0000000 --- a/src/Web/Features/Contents/Migrations/20240725022229_AddMultipleMediaUrlsToContent.Designer.cs +++ /dev/null @@ -1,59 +0,0 @@ -// -using System; -using Hutopy.Web.Features.Contents.Data; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; - -#nullable disable - -namespace Hutopy.Web.Features.Contents.Migrations -{ - [DbContext(typeof(ContentDbContext))] - [Migration("20240725022229_AddMultipleMediaUrlsToContent")] - partial class AddMultipleMediaUrlsToContent - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasDefaultSchema("Content") - .HasAnnotation("ProductVersion", "8.0.4") - .HasAnnotation("Relational:MaxIdentifierLength", 63); - - NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); - - modelBuilder.Entity("Hutopy.Web.Features.Contents.Data.Content", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property("CreatedAt") - .ValueGeneratedOnAdd() - .HasColumnType("timestamp with time zone") - .HasDefaultValueSql("CURRENT_TIMESTAMP"); - - b.Property("CreatedBy") - .HasColumnType("uuid"); - - b.Property("Description") - .HasColumnType("text"); - - b.Property("Title") - .HasColumnType("text"); - - b.Property("Urls") - .HasColumnType("text[]"); - - b.HasKey("Id"); - - b.ToTable("Contents", "Content"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/Web/Features/Contents/Migrations/20240725022229_AddMultipleMediaUrlsToContent.cs b/src/Web/Features/Contents/Migrations/20240725022229_AddMultipleMediaUrlsToContent.cs deleted file mode 100644 index 74051db..0000000 --- a/src/Web/Features/Contents/Migrations/20240725022229_AddMultipleMediaUrlsToContent.cs +++ /dev/null @@ -1,42 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Hutopy.Web.Features.Contents.Migrations -{ - /// - public partial class AddMultipleMediaUrlsToContent : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "Uri", - schema: "Content", - table: "Contents"); - - migrationBuilder.AddColumn( - name: "Urls", - schema: "Content", - table: "Contents", - type: "text[]", - nullable: true); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "Urls", - schema: "Content", - table: "Contents"); - - migrationBuilder.AddColumn( - name: "Uri", - schema: "Content", - table: "Contents", - type: "text", - nullable: true); - } - } -} diff --git a/src/Web/Features/Contents/Migrations/20240802044656_Initial.Designer.cs b/src/Web/Features/Contents/Migrations/20240802044656_Initial.Designer.cs new file mode 100644 index 0000000..f14eda2 --- /dev/null +++ b/src/Web/Features/Contents/Migrations/20240802044656_Initial.Designer.cs @@ -0,0 +1,214 @@ +// +using System; +using Hutopy.Web.Features.Contents.Data; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace Hutopy.Web.Features.Contents.Migrations +{ + [DbContext(typeof(ContentDbContext))] + [Migration("20240802044656_Initial")] + partial class Initial + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasDefaultSchema("Content") + .HasAnnotation("ProductVersion", "8.0.4") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("Hutopy.Web.Features.Contents.Data.Content", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("Description") + .IsRequired() + .HasColumnType("text"); + + b.Property("Title") + .IsRequired() + .HasColumnType("text"); + + b.Property("Urls") + .HasColumnType("text[]"); + + b.HasKey("Id"); + + b.ToTable("Contents", "Content"); + }); + + modelBuilder.Entity("Hutopy.Web.Features.Contents.Data.Creator", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("character varying(255)"); + + b.HasKey("Id"); + + b.ToTable("Creators", "Content"); + }); + + modelBuilder.Entity("Hutopy.Web.Features.Contents.Data.Creator", b => + { + b.OwnsOne("Hutopy.Web.Features.Contents.Data.About", "About", b1 => + { + b1.Property("CreatorId") + .HasColumnType("uuid"); + + b1.Property("Description") + .HasMaxLength(255) + .HasColumnType("character varying(255)"); + + b1.Property("Title") + .HasMaxLength(255) + .HasColumnType("character varying(255)"); + + b1.HasKey("CreatorId"); + + b1.ToTable("Creators", "Content"); + + b1.WithOwner() + .HasForeignKey("CreatorId"); + }); + + b.OwnsOne("Hutopy.Web.Features.Contents.Data.ProfileColors", "ProfileColors", b1 => + { + b1.Property("CreatorId") + .HasColumnType("uuid"); + + b1.Property("Accent") + .HasMaxLength(9) + .HasColumnType("character varying(9)"); + + b1.Property("BannerBottom") + .HasMaxLength(9) + .HasColumnType("character varying(9)"); + + b1.Property("BannerTop") + .HasMaxLength(9) + .HasColumnType("character varying(9)"); + + b1.Property("Menu") + .HasMaxLength(9) + .HasColumnType("character varying(9)"); + + b1.HasKey("CreatorId"); + + b1.ToTable("Creators", "Content"); + + b1.WithOwner() + .HasForeignKey("CreatorId"); + }); + + b.OwnsOne("Hutopy.Web.Features.Contents.Data.SocialNetworks", "SocialNetworks", b1 => + { + b1.Property("CreatorId") + .HasColumnType("uuid"); + + b1.Property("FacebookUrl") + .HasMaxLength(255) + .HasColumnType("character varying(255)"); + + b1.Property("InstagramUrl") + .HasMaxLength(255) + .HasColumnType("character varying(255)"); + + b1.Property("LinkedInUrl") + .HasMaxLength(255) + .HasColumnType("character varying(255)"); + + b1.Property("RedditUrl") + .HasMaxLength(255) + .HasColumnType("character varying(255)"); + + b1.Property("TikTokUrl") + .HasMaxLength(255) + .HasColumnType("character varying(255)"); + + b1.Property("WebsiteUrl") + .HasMaxLength(255) + .HasColumnType("character varying(255)"); + + b1.Property("XUrl") + .HasMaxLength(255) + .HasColumnType("character varying(255)"); + + b1.Property("YoutubeUrl") + .HasMaxLength(255) + .HasColumnType("character varying(255)"); + + b1.HasKey("CreatorId"); + + b1.ToTable("Creators", "Content"); + + b1.WithOwner() + .HasForeignKey("CreatorId"); + }); + + b.OwnsOne("Hutopy.Web.Features.Contents.Data.StoredDataUrls", "StoredDataUrls", b1 => + { + b1.Property("CreatorId") + .HasColumnType("uuid"); + + b1.Property("BannerPictureUrl") + .HasMaxLength(255) + .HasColumnType("character varying(255)"); + + b1.Property("ProfilePictureUrl") + .HasMaxLength(255) + .HasColumnType("character varying(255)"); + + b1.HasKey("CreatorId"); + + b1.ToTable("Creators", "Content"); + + b1.WithOwner() + .HasForeignKey("CreatorId"); + }); + + b.Navigation("About") + .IsRequired(); + + b.Navigation("ProfileColors") + .IsRequired(); + + b.Navigation("SocialNetworks") + .IsRequired(); + + b.Navigation("StoredDataUrls") + .IsRequired(); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/Web/Features/Contents/Migrations/20240802044656_Initial.cs b/src/Web/Features/Contents/Migrations/20240802044656_Initial.cs new file mode 100644 index 0000000..465ecbb --- /dev/null +++ b/src/Web/Features/Contents/Migrations/20240802044656_Initial.cs @@ -0,0 +1,78 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Hutopy.Web.Features.Contents.Migrations +{ + /// + public partial class Initial : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.EnsureSchema( + name: "Content"); + + migrationBuilder.CreateTable( + name: "Contents", + schema: "Content", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + CreatedBy = table.Column(type: "uuid", nullable: false), + CreatedAt = table.Column(type: "timestamp with time zone", nullable: false, defaultValueSql: "CURRENT_TIMESTAMP"), + Title = table.Column(type: "text", nullable: false), + Description = table.Column(type: "text", nullable: false), + Urls = table.Column(type: "text[]", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Contents", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Creators", + schema: "Content", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + CreatedBy = table.Column(type: "uuid", nullable: false), + CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), + Name = table.Column(type: "character varying(255)", maxLength: 255, nullable: false), + About_Title = table.Column(type: "character varying(255)", maxLength: 255, nullable: true), + About_Description = table.Column(type: "character varying(255)", maxLength: 255, nullable: true), + SocialNetworks_FacebookUrl = table.Column(type: "character varying(255)", maxLength: 255, nullable: true), + SocialNetworks_InstagramUrl = table.Column(type: "character varying(255)", maxLength: 255, nullable: true), + SocialNetworks_XUrl = table.Column(type: "character varying(255)", maxLength: 255, nullable: true), + SocialNetworks_LinkedInUrl = table.Column(type: "character varying(255)", maxLength: 255, nullable: true), + SocialNetworks_TikTokUrl = table.Column(type: "character varying(255)", maxLength: 255, nullable: true), + SocialNetworks_YoutubeUrl = table.Column(type: "character varying(255)", maxLength: 255, nullable: true), + SocialNetworks_RedditUrl = table.Column(type: "character varying(255)", maxLength: 255, nullable: true), + SocialNetworks_WebsiteUrl = table.Column(type: "character varying(255)", maxLength: 255, nullable: true), + ProfileColors_BannerTop = table.Column(type: "character varying(9)", maxLength: 9, nullable: true), + ProfileColors_BannerBottom = table.Column(type: "character varying(9)", maxLength: 9, nullable: true), + ProfileColors_Accent = table.Column(type: "character varying(9)", maxLength: 9, nullable: true), + ProfileColors_Menu = table.Column(type: "character varying(9)", maxLength: 9, nullable: true), + StoredDataUrls_BannerPictureUrl = table.Column(type: "character varying(255)", maxLength: 255, nullable: true), + StoredDataUrls_ProfilePictureUrl = table.Column(type: "character varying(255)", maxLength: 255, nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Creators", x => x.Id); + }); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "Contents", + schema: "Content"); + + migrationBuilder.DropTable( + name: "Creators", + schema: "Content"); + } + } +} diff --git a/src/Web/Features/Contents/Migrations/ContentDbContextModelSnapshot.cs b/src/Web/Features/Contents/Migrations/ContentDbContextModelSnapshot.cs index 0bff6dd..920ea8b 100644 --- a/src/Web/Features/Contents/Migrations/ContentDbContextModelSnapshot.cs +++ b/src/Web/Features/Contents/Migrations/ContentDbContextModelSnapshot.cs @@ -8,7 +8,7 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; #nullable disable -namespace Hutopy.Web.Contents.Migrations +namespace Hutopy.Web.Features.Contents.Migrations { [DbContext(typeof(ContentDbContext))] partial class ContentDbContextModelSnapshot : ModelSnapshot @@ -38,9 +38,11 @@ namespace Hutopy.Web.Contents.Migrations .HasColumnType("uuid"); b.Property("Description") + .IsRequired() .HasColumnType("text"); b.Property("Title") + .IsRequired() .HasColumnType("text"); b.Property("Urls") @@ -50,6 +52,159 @@ namespace Hutopy.Web.Contents.Migrations b.ToTable("Contents", "Content"); }); + + modelBuilder.Entity("Hutopy.Web.Features.Contents.Data.Creator", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("character varying(255)"); + + b.HasKey("Id"); + + b.ToTable("Creators", "Content"); + }); + + modelBuilder.Entity("Hutopy.Web.Features.Contents.Data.Creator", b => + { + b.OwnsOne("Hutopy.Web.Features.Contents.Data.About", "About", b1 => + { + b1.Property("CreatorId") + .HasColumnType("uuid"); + + b1.Property("Description") + .HasMaxLength(255) + .HasColumnType("character varying(255)"); + + b1.Property("Title") + .HasMaxLength(255) + .HasColumnType("character varying(255)"); + + b1.HasKey("CreatorId"); + + b1.ToTable("Creators", "Content"); + + b1.WithOwner() + .HasForeignKey("CreatorId"); + }); + + b.OwnsOne("Hutopy.Web.Features.Contents.Data.ProfileColors", "ProfileColors", b1 => + { + b1.Property("CreatorId") + .HasColumnType("uuid"); + + b1.Property("Accent") + .HasMaxLength(9) + .HasColumnType("character varying(9)"); + + b1.Property("BannerBottom") + .HasMaxLength(9) + .HasColumnType("character varying(9)"); + + b1.Property("BannerTop") + .HasMaxLength(9) + .HasColumnType("character varying(9)"); + + b1.Property("Menu") + .HasMaxLength(9) + .HasColumnType("character varying(9)"); + + b1.HasKey("CreatorId"); + + b1.ToTable("Creators", "Content"); + + b1.WithOwner() + .HasForeignKey("CreatorId"); + }); + + b.OwnsOne("Hutopy.Web.Features.Contents.Data.SocialNetworks", "SocialNetworks", b1 => + { + b1.Property("CreatorId") + .HasColumnType("uuid"); + + b1.Property("FacebookUrl") + .HasMaxLength(255) + .HasColumnType("character varying(255)"); + + b1.Property("InstagramUrl") + .HasMaxLength(255) + .HasColumnType("character varying(255)"); + + b1.Property("LinkedInUrl") + .HasMaxLength(255) + .HasColumnType("character varying(255)"); + + b1.Property("RedditUrl") + .HasMaxLength(255) + .HasColumnType("character varying(255)"); + + b1.Property("TikTokUrl") + .HasMaxLength(255) + .HasColumnType("character varying(255)"); + + b1.Property("WebsiteUrl") + .HasMaxLength(255) + .HasColumnType("character varying(255)"); + + b1.Property("XUrl") + .HasMaxLength(255) + .HasColumnType("character varying(255)"); + + b1.Property("YoutubeUrl") + .HasMaxLength(255) + .HasColumnType("character varying(255)"); + + b1.HasKey("CreatorId"); + + b1.ToTable("Creators", "Content"); + + b1.WithOwner() + .HasForeignKey("CreatorId"); + }); + + b.OwnsOne("Hutopy.Web.Features.Contents.Data.StoredDataUrls", "StoredDataUrls", b1 => + { + b1.Property("CreatorId") + .HasColumnType("uuid"); + + b1.Property("BannerPictureUrl") + .HasMaxLength(255) + .HasColumnType("character varying(255)"); + + b1.Property("ProfilePictureUrl") + .HasMaxLength(255) + .HasColumnType("character varying(255)"); + + b1.HasKey("CreatorId"); + + b1.ToTable("Creators", "Content"); + + b1.WithOwner() + .HasForeignKey("CreatorId"); + }); + + b.Navigation("About") + .IsRequired(); + + b.Navigation("ProfileColors") + .IsRequired(); + + b.Navigation("SocialNetworks") + .IsRequired(); + + b.Navigation("StoredDataUrls") + .IsRequired(); + }); #pragma warning restore 612, 618 } } diff --git a/src/Web/Features/Messages/Handlers/AddMessage.cs b/src/Web/Features/Messages/Handlers/AddMessage.cs index dc7c9e2..81c12b8 100644 --- a/src/Web/Features/Messages/Handlers/AddMessage.cs +++ b/src/Web/Features/Messages/Handlers/AddMessage.cs @@ -49,8 +49,8 @@ public class AddMessage( CreatedByName = User.GetAlias() ?? $"{User.GetFirstName()} {User.GetLastName()}", CreatedByPortraitUrl = User.GetPortraitUrl(), Value = req.Message - }; - + }; + await context.Messages.AddAsync(message, ct); await context.SaveChangesAsync(ct); diff --git a/src/Web/Features/Messages/Migrations/20240721041322_Initial.Designer.cs b/src/Web/Features/Messages/Migrations/20240721041322_Initial.Designer.cs deleted file mode 100644 index b864487..0000000 --- a/src/Web/Features/Messages/Migrations/20240721041322_Initial.Designer.cs +++ /dev/null @@ -1,67 +0,0 @@ -// -using System; -using Hutopy.Web.Features.Messages.Data; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; - -#nullable disable - -namespace Hutopy.Web.Features.Messages.Migrations -{ - [DbContext(typeof(MessagingDbContext))] - [Migration("20240721041322_Initial")] - partial class Initial - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasDefaultSchema("Messaging") - .HasAnnotation("ProductVersion", "8.0.4") - .HasAnnotation("Relational:MaxIdentifierLength", 63); - - NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); - - modelBuilder.Entity("Hutopy.Web.Features.Messages.Data.Message", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property("CreatedAt") - .ValueGeneratedOnAdd() - .HasColumnType("timestamp with time zone") - .HasDefaultValueSql("CURRENT_TIMESTAMP"); - - b.Property("CreatedBy") - .HasColumnType("uuid"); - - b.Property("CreatedByName") - .IsRequired() - .HasColumnType("text"); - - b.Property("CreatedByPortraitUrl") - .HasColumnType("text"); - - b.Property("ParentId") - .HasColumnType("uuid"); - - b.Property("SubjectId") - .HasColumnType("uuid"); - - b.Property("Value") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.ToTable("Messages", "Messaging"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/Web/Features/Messages/Migrations/20240721064224_ChangedAuthorDefinition.cs b/src/Web/Features/Messages/Migrations/20240721064224_ChangedAuthorDefinition.cs deleted file mode 100644 index bf04dbe..0000000 --- a/src/Web/Features/Messages/Migrations/20240721064224_ChangedAuthorDefinition.cs +++ /dev/null @@ -1,60 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Hutopy.Web.Features.Messages.Migrations -{ - /// - public partial class ChangedAuthorDefinition : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AlterColumn( - name: "CreatedByPortraitUrl", - schema: "Messaging", - table: "Messages", - type: "character varying(256)", - maxLength: 256, - nullable: true, - oldClrType: typeof(string), - oldType: "text", - oldNullable: true); - - migrationBuilder.AlterColumn( - name: "CreatedByName", - schema: "Messaging", - table: "Messages", - type: "character varying(64)", - maxLength: 64, - nullable: false, - oldClrType: typeof(string), - oldType: "text"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.AlterColumn( - name: "CreatedByPortraitUrl", - schema: "Messaging", - table: "Messages", - type: "text", - nullable: true, - oldClrType: typeof(string), - oldType: "character varying(256)", - oldMaxLength: 256, - oldNullable: true); - - migrationBuilder.AlterColumn( - name: "CreatedByName", - schema: "Messaging", - table: "Messages", - type: "text", - nullable: false, - oldClrType: typeof(string), - oldType: "character varying(64)", - oldMaxLength: 64); - } - } -} diff --git a/src/Web/Features/Messages/Migrations/20240721064224_ChangedAuthorDefinition.Designer.cs b/src/Web/Features/Messages/Migrations/20240802044717_Initial.Designer.cs similarity index 95% rename from src/Web/Features/Messages/Migrations/20240721064224_ChangedAuthorDefinition.Designer.cs rename to src/Web/Features/Messages/Migrations/20240802044717_Initial.Designer.cs index 1a92049..63d787f 100644 --- a/src/Web/Features/Messages/Migrations/20240721064224_ChangedAuthorDefinition.Designer.cs +++ b/src/Web/Features/Messages/Migrations/20240802044717_Initial.Designer.cs @@ -12,8 +12,8 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; namespace Hutopy.Web.Features.Messages.Migrations { [DbContext(typeof(MessagingDbContext))] - [Migration("20240721064224_ChangedAuthorDefinition")] - partial class ChangedAuthorDefinition + [Migration("20240802044717_Initial")] + partial class Initial { /// protected override void BuildTargetModel(ModelBuilder modelBuilder) diff --git a/src/Web/Features/Messages/Migrations/20240721041322_Initial.cs b/src/Web/Features/Messages/Migrations/20240802044717_Initial.cs similarity index 93% rename from src/Web/Features/Messages/Migrations/20240721041322_Initial.cs rename to src/Web/Features/Messages/Migrations/20240802044717_Initial.cs index 7287c65..fa9c144 100644 --- a/src/Web/Features/Messages/Migrations/20240721041322_Initial.cs +++ b/src/Web/Features/Messages/Migrations/20240802044717_Initial.cs @@ -22,8 +22,8 @@ namespace Hutopy.Web.Features.Messages.Migrations Id = table.Column(type: "uuid", nullable: false), SubjectId = table.Column(type: "uuid", nullable: false), CreatedBy = table.Column(type: "uuid", nullable: false), - CreatedByName = table.Column(type: "text", nullable: false), - CreatedByPortraitUrl = table.Column(type: "text", nullable: true), + CreatedByName = table.Column(type: "character varying(64)", maxLength: 64, nullable: false), + CreatedByPortraitUrl = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), CreatedAt = table.Column(type: "timestamp with time zone", nullable: false, defaultValueSql: "CURRENT_TIMESTAMP"), ParentId = table.Column(type: "uuid", nullable: true), Value = table.Column(type: "text", nullable: false) diff --git a/src/Web/Services/CurrentUser.cs b/src/Web/Services/CurrentUser.cs index 50a502a..29003d5 100644 --- a/src/Web/Services/CurrentUser.cs +++ b/src/Web/Services/CurrentUser.cs @@ -1,6 +1,5 @@ -using System.Security.Claims; - -using Hutopy.Application.Common.Interfaces; +using Hutopy.Application.Common.Interfaces; +using Hutopy.Web.Common; namespace Hutopy.Web.Services; @@ -8,5 +7,5 @@ public class CurrentUser( IHttpContextAccessor httpContextAccessor) : IUser { - public string? Id => httpContextAccessor.HttpContext?.User?.FindFirstValue(ClaimTypes.NameIdentifier); + public Guid? Id => httpContextAccessor.HttpContext?.User.GetUserId(); } diff --git a/src/Web/TestDataSeeder.cs b/src/Web/TestDataSeeder.cs index cb713f9..fb87568 100644 --- a/src/Web/TestDataSeeder.cs +++ b/src/Web/TestDataSeeder.cs @@ -1,6 +1,5 @@ using Hutopy.Domain.Constants; using Hutopy.Infrastructure.Identity; -using Hutopy.Infrastructure.Identity.OwnedEntities; using Hutopy.Web.Common; using Hutopy.Web.Features.Contents.Data; using Hutopy.Web.Features.Messages.Data; @@ -38,10 +37,14 @@ internal class TestDataSeeder( _users.Add(await CreateUserAsync("admin", Roles.Administrator)); _users.Add(await CreateUserAsync("userA")); _users.Add(await CreateUserAsync("userB")); - + foreach (var creator in _creators) { - _users.Add(await CreateCreatorAsync(creator)); + var creatorUser = await CreateUserAsync(creator.Name, Roles.Creator); + + creator.Id = creatorUser.Id; + + await contentContext.Creators.AddAsync(creator); var contents = GenerateContent(creator, 100); foreach (var content in contents) @@ -59,7 +62,7 @@ internal class TestDataSeeder( } } - private List GenerateContent(ApplicationUser user, int contentCount) + private List GenerateContent(Creator creator, int contentCount) { var currentDate = DateTimeOffset.UtcNow; @@ -70,10 +73,10 @@ internal class TestDataSeeder( var content = new Content { Id = GuidHelper.GenerateUuidV7(), - CreatedBy = Guid.Parse(user.Id), + CreatedBy = creator.Id, CreatedAt = currentDate, - Title = $"Title {user.UserName}-{c}", - Description = $"Description {user.UserName}-{c}" + Title = $"Title {creator.Name}-{c}", + Description = $"Description {creator.Name}-{c}" }; contentContext.Contents.Add(content); @@ -103,9 +106,9 @@ internal class TestDataSeeder( Id = GuidHelper.GenerateUuidV7(), SubjectId = content.Id, CreatedAt = currentDate, - CreatedBy = Guid.Parse(author.Id), + CreatedBy = author.Id, CreatedByName = author.Alias ?? $"{author.FirstName} {author.LastName}", - CreatedByPortraitUrl = author.StoredDataUrls.ProfilePictureUrl, + CreatedByPortraitUrl = author.PortraitUrl, Value = $"Message #{m} on {content.Title}" }; @@ -133,9 +136,9 @@ internal class TestDataSeeder( Id = GuidHelper.GenerateUuidV7(), SubjectId = content.Id, ParentId = parent.Id, - CreatedBy = Guid.Parse(author.Id), + CreatedBy = author.Id, CreatedByName = author.Alias ?? $"{author.FirstName} {author.LastName}", - CreatedByPortraitUrl = author.StoredDataUrls.ProfilePictureUrl, + CreatedByPortraitUrl = author.PortraitUrl, CreatedAt = currentDate, Value = $"Reply {r} to {parent.Value} on {content.Title}" }; @@ -167,49 +170,38 @@ internal class TestDataSeeder( return user; } - private async Task CreateCreatorAsync(ApplicationUser creator) - { - await userManager.CreateAsync(creator, DefaultPassword); - await userManager.AddToRolesAsync(creator, new[] { Roles.Creator }); - return creator; - } - - private readonly List _users = [ ]; - - private readonly static ApplicationUser Hutopy = new() + private readonly static Creator HutopyCreator = new() { - UserName = "hutopy@test", - Email = "hutopy@test", - EmailConfirmed = true, - CreatorAlias = "hutopy", - FirstName = "FirstName of a Brand/Creator", - LastName = "LastName of a Brand/Creator", - About = "Page officielle", - Description = "Site officiel pour Hutopy. Venez-nous-y retrouver avec tous vos fans!", - ProfileColors = new ProfileColors + Name = "hutopy", + About = new() { - BannerTop = "A30E79", BannerBottom = "6B0065", Accent = "23393B", Menu = "53B93B", + Title = "Page officielle", + Description = "Site officiel pour Hutopy. Venez-nous-y retrouver avec tous vos fans!", + }, + ProfileColors = new() + { + BannerTop = "#A30E79", BannerBottom = "#6B0065", Accent = "#23393B", Menu = "#53B93B", }, SocialNetworks = - new SocialNetworks + new() { XUrl = "https://twitter.com/Hutopyinc", FacebookUrl = "https://www.facebook.com/Hutopy", InstagramUrl = "https://www.instagram.com/hutopy.inc/" }, - StoredDataUrls = new StoredDataUrls + StoredDataUrls = new() { BannerPictureUrl = "/images/usersmedia/HutopyProfile/banners/banner01.png", ProfilePictureUrl = "/images/usersmedia/HutopyProfile/profilepictures/profileHutopyProfile01.png" } }; - private readonly ApplicationUser[] _creators = + private readonly Creator[] _creators = [ - Hutopy + HutopyCreator ]; } diff --git a/src/Web/Web.csproj b/src/Web/Web.csproj index ba72aba..605e476 100644 --- a/src/Web/Web.csproj +++ b/src/Web/Web.csproj @@ -32,4 +32,9 @@ + + + + + diff --git a/tests/Application.FunctionalTests/Testing.cs b/tests/Application.FunctionalTests/Testing.cs index 8c31c56..74cd4d0 100644 --- a/tests/Application.FunctionalTests/Testing.cs +++ b/tests/Application.FunctionalTests/Testing.cs @@ -14,7 +14,7 @@ public partial class Testing private static ITestDatabase _database; private static CustomWebApplicationFactory _factory = null!; private static IServiceScopeFactory _scopeFactory = null!; - private static string? _userId; + private static Guid _userId; [OneTimeSetUp] public async Task RunBeforeAnyTests() @@ -44,32 +44,36 @@ public partial class Testing await mediator.Send(request); } - public static string? GetUserId() + public static Guid GetUserId() { return _userId; } - public static async Task RunAsDefaultUserAsync() + public static async Task RunAsDefaultUserAsync() { - return await RunAsUserAsync("test@local", "Testing1234!", Array.Empty()); + return await RunAsUserAsync( + "test@local", + "Testing1234!", + []); } - public static async Task RunAsAdministratorAsync() + public static async Task RunAsAdministratorAsync() { - return await RunAsUserAsync("administrator@local", "Administrator1234!", new[] { Roles.Administrator }); + return await RunAsUserAsync( + "administrator@local", + "Administrator1234!", + [Roles.Administrator]); } - public static async Task RunAsUserAsync(string userName, string password, string[] roles) + public static async Task RunAsUserAsync(string userName, string password, string[] roles) { using var scope = _scopeFactory.CreateScope(); var userManager = scope.ServiceProvider.GetRequiredService(); - var user = new ApplicationUser { - UserName = userName, - Email = userName, - FirstName = "FirstName", - LastName = "LastName" + var user = new ApplicationUser + { + UserName = userName, Email = userName, FirstName = "FirstName", LastName = "LastName" }; var result = await userManager.CreateAsync(user, password); @@ -104,11 +108,11 @@ public partial class Testing { await _database.ResetAsync(); } - catch (Exception) + catch (Exception) { } - _userId = null; + _userId = Guid.Empty; } public static async Task FindAsync(params object[] keyValues) diff --git a/tests/Application.UnitTests/Common/Behaviours/RequestLoggerTests.cs b/tests/Application.UnitTests/Common/Behaviours/RequestLoggerTests.cs index 28b4f49..a6fc766 100644 --- a/tests/Application.UnitTests/Common/Behaviours/RequestLoggerTests.cs +++ b/tests/Application.UnitTests/Common/Behaviours/RequestLoggerTests.cs @@ -1,6 +1,4 @@ -using Hutopy.Application.Common.Behaviours; -using Hutopy.Application.Common.Interfaces; -using Microsoft.Extensions.Logging; +using Hutopy.Application.Common.Interfaces; using Moq; using NUnit.Framework; diff --git a/tests/Application.UnitTests/Common/Mappings/MappingTests.cs b/tests/Application.UnitTests/Common/Mappings/MappingTests.cs index fcd2b2a..e95ed50 100644 --- a/tests/Application.UnitTests/Common/Mappings/MappingTests.cs +++ b/tests/Application.UnitTests/Common/Mappings/MappingTests.cs @@ -2,8 +2,6 @@ using System.Runtime.CompilerServices; using AutoMapper; using Hutopy.Application.Common.Interfaces; -using Hutopy.Application.Common.Models; -using Hutopy.Domain.Entities; using NUnit.Framework; namespace Hutopy.Application.UnitTests.Common.Mappings;