From bd6028c524913d9ca988efdc9c8a0e72b557711e Mon Sep 17 00:00:00 2001 From: Dominic Villemure Date: Mon, 22 Apr 2024 16:34:17 -0400 Subject: [PATCH] #27 saveChanges --- .../Stripe/Commands/CreateSessionCheckoutCommand.cs | 2 ++ src/Infrastructure/Services/UserService.cs | 9 ++++----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/Application/Stripe/Commands/CreateSessionCheckoutCommand.cs b/src/Application/Stripe/Commands/CreateSessionCheckoutCommand.cs index e627bf1..9014f97 100644 --- a/src/Application/Stripe/Commands/CreateSessionCheckoutCommand.cs +++ b/src/Application/Stripe/Commands/CreateSessionCheckoutCommand.cs @@ -27,6 +27,8 @@ public class CreateSessionCheckoutCommandHandler( await dbContext.UserTransactions.AddAsync(userTransaction, cancellationToken); + await dbContext.SaveChangesAsync(cancellationToken); + return stripeSecret; } } diff --git a/src/Infrastructure/Services/UserService.cs b/src/Infrastructure/Services/UserService.cs index 7fae66c..b0704c2 100644 --- a/src/Infrastructure/Services/UserService.cs +++ b/src/Infrastructure/Services/UserService.cs @@ -1,13 +1,11 @@ -using System.Security.Claims; -using Hutopy.Domain.Interfaces; +using Hutopy.Domain.Interfaces; using Hutopy.Domain.Models; using Hutopy.Infrastructure.Identity; -using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Identity; namespace Hutopy.Infrastructure.Services; -public class UserService(UserManager userManager, IHttpContextAccessor httpContextAccessor) : IUserService +public class UserService(UserManager userManager) : IUserService { public async Task CreateUserAsync(string email, string userName, string firstName, string lastName, string password) { @@ -48,7 +46,8 @@ public class UserService(UserManager userManager, IHttpContextA public async Task GetCurrentUserAsync() { - var userId = httpContextAccessor.HttpContext?.User.FindFirstValue(ClaimTypes.NameIdentifier); + // todo: Get the id of the user doing the request. + var userId = ""; if (string.IsNullOrEmpty(userId)) { return null;