chatbot/Chatbot.Api.Domain.Data/Repositories/SessionRepository.cs

37 lines
1.0 KiB
C#
Raw Normal View History

2020-06-06 19:21:40 +03:00
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;
}
}
}