37 lines
1.0 KiB
C#
37 lines
1.0 KiB
C#
|
using Chatbot.Api.Domain.Data.DbContexts;
|
|||
|
using Chatbot.Api.Domain.Entities;
|
|||
|
using Chatbot.Api.Domain.Repositories;
|
|||
|
using System;
|
|||
|
using System.Threading.Tasks;
|
|||
|
|
|||
|
namespace Chatbot.Api.Domain.Data.Repositories
|
|||
|
{
|
|||
|
public class SessionRepository : ISessionRepository
|
|||
|
{
|
|||
|
private readonly SessionDbContext _dbContext;
|
|||
|
|
|||
|
public SessionRepository(SessionDbContext dbContext)
|
|||
|
{
|
|||
|
_dbContext = dbContext;
|
|||
|
}
|
|||
|
|
|||
|
public async Task<BotSession> CreateSession(Guid botId, string clientApplication, string externalId, string userKey)
|
|||
|
{
|
|||
|
var session = new BotSession()
|
|||
|
{
|
|||
|
SessionId = Guid.NewGuid(),
|
|||
|
StartDate = DateTime.Now,
|
|||
|
BotId = botId,
|
|||
|
ClientApplication = clientApplication,
|
|||
|
ExternalId = externalId,
|
|||
|
UserKey = userKey
|
|||
|
};
|
|||
|
|
|||
|
_dbContext.Add(session);
|
|||
|
await _dbContext.SaveChangesAsync();
|
|||
|
|
|||
|
return session;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|