Poszukiwacz/Serwer/Serwer.Infrastructure/Services/HistoryService.cs
2021-01-09 14:44:14 +01:00

33 lines
983 B
C#

using Serwer.Core.Domain;
using Serwer.Core.Repositories;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Serwer.Infrastructure.Services
{
public class HistoryService: IHistoryService
{
private readonly IHistoryRepository _historyRepository;
private readonly IUserRepository _userRepository;
public HistoryService(IHistoryRepository historyRepository, IUserRepository userRepository)
{
_historyRepository = historyRepository;
_userRepository = userRepository;
}
public async Task<UserHistory> GetAsync(Guid userId)
{
var user = await _userRepository.GetAsync(userId);
if(user == null)
{
throw new Exception("Coś poszło nie tak.");
}
var history = await _historyRepository.GetAsync(user);
return history;
}
}
}