using Serwer.Core.Domain; using Serwer.Core.Repositories; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; namespace Serwer.Infrastructure.Repositories { public class HistoryRepository: IHistoryRepository { private static ISet _history = new HashSet(); public async Task AddAsync(User user, string query) { var history = _history.FirstOrDefault(x => x.User.Id == user.Id); if(history == null) { history = new UserHistory(user); } history.Add(query); await Task.FromResult(_history.Add(history)); } public async Task GetAsync(User user) { var history = _history.FirstOrDefault(x => x.User.Id == user.Id); return await Task.FromResult(history); } } }