Skip to content

Commit 9ed8011

Browse files
committed
moved and renamed conversation state entity.
1 parent 18c4c2e commit 9ed8011

File tree

5 files changed

+13
-14
lines changed

5 files changed

+13
-14
lines changed

RedmineTelegramBot.Core/ConversationHandler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public class ConversationHandler : IConversationHandler
1616
private readonly IUserSettingsRepository _userSettingsRepository;
1717
private readonly IConversationStateRepository _conversationStateRepository;
1818

19-
private ConversationStateModel _conversationState;
19+
private ConversationState _conversationState;
2020

2121
public ConversationHandler(
2222
IWorkContext workContext,

RedmineTelegramBot.Core/Models/ConversationStateModel.cs renamed to RedmineTelegramBot.Core/Data/ConversationState.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
using System;
1+
using RedmineTelegramBot.Core.Models;
2+
using System;
23
using System.Collections.Generic;
34
using System.Linq;
45
using System.Text;
56
using System.Threading.Tasks;
67

7-
namespace RedmineTelegramBot.Core.Models
8+
namespace RedmineTelegramBot.Core.Data
89
{
9-
public class ConversationStateModel
10+
public class ConversationState
1011
{
1112
public long ChatId { get; set; }
1213

RedmineTelegramBot.Core/Data/IConversationStateRepository.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
using RedmineTelegramBot.Core.Models;
2-
using System;
1+
using System;
32
using System.Collections.Generic;
43
using System.Linq;
54
using System.Text;
@@ -9,9 +8,9 @@ namespace RedmineTelegramBot.Core.Data
98
{
109
public interface IConversationStateRepository
1110
{
12-
ConversationStateModel GetConversationState(string username);
11+
ConversationState GetConversationState(string username);
1312

14-
void StoreConversationState(ConversationStateModel conversationState);
13+
void StoreConversationState(ConversationState conversationState);
1514

1615
void DeleteConversationState(string username);
1716
}

RedmineTelegramBot.Core/Data/InMemoryConversationStateRepository.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
using RedmineTelegramBot.Core.Models;
2-
using System.Collections.Generic;
1+
using System.Collections.Generic;
32
using System.Text.Json;
43

54
namespace RedmineTelegramBot.Core.Data
@@ -22,17 +21,17 @@ public void DeleteConversationState(string username)
2221
_store.Remove(username);
2322
}
2423

25-
public ConversationStateModel GetConversationState(string username)
24+
public ConversationState GetConversationState(string username)
2625
{
2726
if (_store.ContainsKey(username))
2827
{
29-
return JsonSerializer.Deserialize<ConversationStateModel>(_store[username]);
28+
return JsonSerializer.Deserialize<ConversationState>(_store[username]);
3029
}
3130

3231
return null;
3332
}
3433

35-
public void StoreConversationState(ConversationStateModel conversationState)
34+
public void StoreConversationState(ConversationState conversationState)
3635
{
3736
_store[conversationState.Username] = JsonSerializer.Serialize(conversationState);
3837
}

RedmineTelegramBot.Core/RedmineBot.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ private async Task HandleRequest(Message message, string username, long chatId)
9090
var conversationState = conversationStateRepo.GetConversationState(username);
9191
if (conversationState == null)
9292
{
93-
conversationState = new ConversationStateModel()
93+
conversationState = new ConversationState()
9494
{
9595
ChatId = chatId,
9696
Username = username

0 commit comments

Comments
 (0)