Skip to main content
Namespace: Numa.Services
Related Models: Conversation.cs
Related Interfaces: IConversationService.cs

Fields

Field NameTypeDescription
_dbContextFactoryIDbContextFactory<NumaContext>DbContextFactory for instantiating instances of NumaContext on-demand

Constructor

public ConversationService( IDbContextFactory<NumaContext> dbContextFactory )
{
    _dbContextFactory = dbContextFactory ?? throw new ArgumentNullException( nameof( dbContextFactory ) );
}

Properties

Property NameTypeDescription
ActiveConversationConversation?Object to represent the state of the currently selected conversation

Methods

Method NameDescriptionParametersReturn Type
GetConversationsByUserIdAsyncGets all conversations available to user in descending order by their UpdateDatetimestringTask<List<Conversation>>
SetActiveConversationSets the ActiveConversation property using a Conversation objectConversationvoid
SetActiveConversationByIdAsyncSets the ActiveConversation property using a Conversation.IdstringTask
SetActiveConversationToNullSets the ActiveConversation to nullvoid
AddConversationAsyncAdds a Conversation to the Cosmos DBConversationTask
UpdateConversationLastMessageUpdates the LastMessage of a Conversation in the Cosmos DBstring,stringTask

IConversationService.cs

using Numa.Models;

namespace Numa.Interfaces
{
    public interface IConversationService
    {
        Conversation? ActiveConversation { get; }
        Task<List<Conversation>> GetConversationsByUserIdAsync( string userId );
        Task SetActiveConversationByIdAsync( string conversationId );
        void SetActiveConversation( Conversation conversation );
        void SetActiveConversationToNull();
        Task AddConversationAsync( Conversation newConversation );
        Task UpdateConversationLastMessage( string conversationId, string inputMessage );
    }
}