Fix history
This commit is contained in:
parent
46b97ec42f
commit
dd6a16df54
14
Serwer/Serwer.Infrastructure/DTO/UserHistoryDto.cs
Normal file
14
Serwer/Serwer.Infrastructure/DTO/UserHistoryDto.cs
Normal file
@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Serwer.Infrastructure.DTO
|
||||
{
|
||||
public class UserHistoryDto
|
||||
{
|
||||
public List<string> History { get; set; }
|
||||
public UserDto User { get; set; }
|
||||
}
|
||||
}
|
@ -15,6 +15,7 @@ namespace Serwer.Infrastructure.Mappers
|
||||
=> new MapperConfiguration(cfg =>
|
||||
{
|
||||
cfg.CreateMap<User, UserDto>();
|
||||
cfg.CreateMap<UserHistory, UserHistoryDto>();
|
||||
})
|
||||
.CreateMapper();
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
using Serwer.Core.Domain;
|
||||
using AutoMapper;
|
||||
using Serwer.Core.Domain;
|
||||
using Serwer.Core.Repositories;
|
||||
using Serwer.Infrastructure.DTO;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@ -12,13 +14,15 @@ namespace Serwer.Infrastructure.Services
|
||||
{
|
||||
private readonly IHistoryRepository _historyRepository;
|
||||
private readonly IUserRepository _userRepository;
|
||||
public HistoryService(IHistoryRepository historyRepository, IUserRepository userRepository)
|
||||
private readonly IMapper _mapper;
|
||||
public HistoryService(IHistoryRepository historyRepository, IUserRepository userRepository, IMapper mapper)
|
||||
{
|
||||
_historyRepository = historyRepository;
|
||||
_userRepository = userRepository;
|
||||
_mapper = mapper;
|
||||
}
|
||||
|
||||
public async Task<UserHistory> GetAsync(Guid userId)
|
||||
public async Task<UserHistoryDto> GetAsync(Guid userId)
|
||||
{
|
||||
var user = await _userRepository.GetAsync(userId);
|
||||
if(user == null)
|
||||
@ -26,7 +30,7 @@ namespace Serwer.Infrastructure.Services
|
||||
throw new Exception("Coś poszło nie tak.");
|
||||
}
|
||||
var history = await _historyRepository.GetAsync(user);
|
||||
return history;
|
||||
return _mapper.Map<UserHistoryDto>(history);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
using Serwer.Core.Domain;
|
||||
using Serwer.Infrastructure.DTO;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@ -9,6 +10,6 @@ namespace Serwer.Infrastructure.Services
|
||||
{
|
||||
public interface IHistoryService
|
||||
{
|
||||
Task<UserHistory> GetAsync(Guid userId);
|
||||
Task<UserHistoryDto> GetAsync(Guid userId);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user