diff --git a/ShoppingAssistantApi.Application/IRepositories/IWishlistRepository.cs b/ShoppingAssistantApi.Application/IRepositories/IWishlistRepository.cs index e9a9368..cfc5e36 100644 --- a/ShoppingAssistantApi.Application/IRepositories/IWishlistRepository.cs +++ b/ShoppingAssistantApi.Application/IRepositories/IWishlistRepository.cs @@ -8,5 +8,5 @@ public interface IWishlistsRepository : IBaseRepository { Task GetWishlistAsync(Expression> predicate, CancellationToken cancellationToken); - Task UpdateWishlistNameAsync(ObjectId id, string name, CancellationToken cancellationToken); + Task UpdateWishlistNameAsync(ObjectId id, string name, ObjectId updatedById, CancellationToken cancellationToken); } diff --git a/ShoppingAssistantApi.Infrastructure/Services/WishlistsService.cs b/ShoppingAssistantApi.Infrastructure/Services/WishlistsService.cs index 1773a9f..b6814bb 100644 --- a/ShoppingAssistantApi.Infrastructure/Services/WishlistsService.cs +++ b/ShoppingAssistantApi.Infrastructure/Services/WishlistsService.cs @@ -94,7 +94,8 @@ public class WishlistsService : IWishlistsService var openAiMessage = await _openAiService.GetChatCompletion(chatCompletionRequest, cancellationToken); - wishlist = await _wishlistsRepository.UpdateWishlistNameAsync(wishlist.Id, openAiMessage.Content, cancellationToken); + wishlist = await _wishlistsRepository.UpdateWishlistNameAsync(wishlist.Id, + openAiMessage.Content, (ObjectId) GlobalUser.Id, cancellationToken); return _mapper.Map(wishlist); } diff --git a/ShoppingAssistantApi.Persistance/Repositories/WishlistsRepository.cs b/ShoppingAssistantApi.Persistance/Repositories/WishlistsRepository.cs index 63d533c..d015cf8 100644 --- a/ShoppingAssistantApi.Persistance/Repositories/WishlistsRepository.cs +++ b/ShoppingAssistantApi.Persistance/Repositories/WishlistsRepository.cs @@ -1,7 +1,6 @@ using System.Linq.Expressions; using MongoDB.Bson; using MongoDB.Driver; -using ShoppingAssistantApi.Application.GlobalInstances; using ShoppingAssistantApi.Application.IRepositories; using ShoppingAssistantApi.Domain.Entities; using ShoppingAssistantApi.Persistance.Database; @@ -17,14 +16,15 @@ public class WishlistsRepository : BaseRepository, IWishlistsRepositor return await (await _collection.FindAsync(predicate)).FirstOrDefaultAsync(cancellationToken); } - public async Task UpdateWishlistNameAsync(ObjectId wishlistId, string newName, CancellationToken cancellationToken) + public async Task UpdateWishlistNameAsync(ObjectId wishlistId, string newName, + ObjectId updatedById, CancellationToken cancellationToken) { var filterDefinition = Builders.Filter.Eq(w => w.Id, wishlistId); var updateDefinition = Builders.Update .Set(w => w.Name, newName) .Set(w => w.LastModifiedDateUtc, DateTime.UtcNow) - .Set(w => w.LastModifiedById, GlobalUser.Id); + .Set(w => w.LastModifiedById, updatedById); var options = new FindOneAndUpdateOptions {