chatbot/Chatbot.Domain.Data/Repositories/ChatRepository.cs

34 lines
807 B
C#
Raw Normal View History

2020-06-06 23:18:41 +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
{
class ChatRepository : IChatRepository
{
private readonly ChatDbContext _dbContext;
public ChatRepository(ChatDbContext dbContext)
{
_dbContext = dbContext;
}
public async Task<Chat> CreateChat(Guid sessionId)
{
var chat = new Chat()
{
ChatId = Guid.NewGuid(),
SessionId = sessionId,
StartDate = DateTime.Now
};
_dbContext.Add(chat);
await _dbContext.SaveChangesAsync();
return chat;
}
}
}