mirror of
https://github.com/Shchoholiev/shopping-assistant-api.git
synced 2025-04-03 16:19:46 +00:00
remove GlobalUser reference from WishlistRepository
This commit is contained in:
parent
0d97d552e3
commit
422b6085ce
@ -8,5 +8,5 @@ public interface IWishlistsRepository : IBaseRepository<Wishlist>
|
||||
{
|
||||
Task<Wishlist> GetWishlistAsync(Expression<Func<Wishlist, bool>> predicate, CancellationToken cancellationToken);
|
||||
|
||||
Task<Wishlist> UpdateWishlistNameAsync(ObjectId id, string name, CancellationToken cancellationToken);
|
||||
Task<Wishlist> UpdateWishlistNameAsync(ObjectId id, string name, ObjectId updatedById, CancellationToken cancellationToken);
|
||||
}
|
||||
|
@ -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<WishlistDto>(wishlist);
|
||||
}
|
||||
|
@ -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<Wishlist>, IWishlistsRepositor
|
||||
return await (await _collection.FindAsync(predicate)).FirstOrDefaultAsync(cancellationToken);
|
||||
}
|
||||
|
||||
public async Task<Wishlist> UpdateWishlistNameAsync(ObjectId wishlistId, string newName, CancellationToken cancellationToken)
|
||||
public async Task<Wishlist> UpdateWishlistNameAsync(ObjectId wishlistId, string newName,
|
||||
ObjectId updatedById, CancellationToken cancellationToken)
|
||||
{
|
||||
var filterDefinition = Builders<Wishlist>.Filter.Eq(w => w.Id, wishlistId);
|
||||
|
||||
var updateDefinition = Builders<Wishlist>.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<Wishlist>
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user