POS_Sprint_6 #8
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 =>
|
=> new MapperConfiguration(cfg =>
|
||||||
{
|
{
|
||||||
cfg.CreateMap<User, UserDto>();
|
cfg.CreateMap<User, UserDto>();
|
||||||
|
cfg.CreateMap<UserHistory, UserHistoryDto>();
|
||||||
})
|
})
|
||||||
.CreateMapper();
|
.CreateMapper();
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
using Serwer.Core.Domain;
|
using AutoMapper;
|
||||||
|
using Serwer.Core.Domain;
|
||||||
using Serwer.Core.Repositories;
|
using Serwer.Core.Repositories;
|
||||||
|
using Serwer.Infrastructure.DTO;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@ -12,13 +14,15 @@ namespace Serwer.Infrastructure.Services
|
|||||||
{
|
{
|
||||||
private readonly IHistoryRepository _historyRepository;
|
private readonly IHistoryRepository _historyRepository;
|
||||||
private readonly IUserRepository _userRepository;
|
private readonly IUserRepository _userRepository;
|
||||||
public HistoryService(IHistoryRepository historyRepository, IUserRepository userRepository)
|
private readonly IMapper _mapper;
|
||||||
|
public HistoryService(IHistoryRepository historyRepository, IUserRepository userRepository, IMapper mapper)
|
||||||
{
|
{
|
||||||
_historyRepository = historyRepository;
|
_historyRepository = historyRepository;
|
||||||
_userRepository = userRepository;
|
_userRepository = userRepository;
|
||||||
|
_mapper = mapper;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<UserHistory> GetAsync(Guid userId)
|
public async Task<UserHistoryDto> GetAsync(Guid userId)
|
||||||
{
|
{
|
||||||
var user = await _userRepository.GetAsync(userId);
|
var user = await _userRepository.GetAsync(userId);
|
||||||
if(user == null)
|
if(user == null)
|
||||||
@ -26,7 +30,7 @@ namespace Serwer.Infrastructure.Services
|
|||||||
throw new Exception("Coś poszło nie tak.");
|
throw new Exception("Coś poszło nie tak.");
|
||||||
}
|
}
|
||||||
var history = await _historyRepository.GetAsync(user);
|
var history = await _historyRepository.GetAsync(user);
|
||||||
return history;
|
return _mapper.Map<UserHistoryDto>(history);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using Serwer.Core.Domain;
|
using Serwer.Core.Domain;
|
||||||
|
using Serwer.Infrastructure.DTO;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@ -9,6 +10,6 @@ namespace Serwer.Infrastructure.Services
|
|||||||
{
|
{
|
||||||
public interface IHistoryService
|
public interface IHistoryService
|
||||||
{
|
{
|
||||||
Task<UserHistory> GetAsync(Guid userId);
|
Task<UserHistoryDto> GetAsync(Guid userId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user