SES-105 list of logged charcters #36
@ -10,7 +10,7 @@ namespace SessionCompanion.Services.Interfaces
|
||||
{
|
||||
public interface ICharacterService : IServiceBase<CharacterViewModel, Character>
|
||||
{
|
||||
Task<CharacterBasicStatsViewModel> GetBasicCharacterData(int characterId);
|
||||
Task<IEnumerable<CharacterBasicStatsViewModel>> GetBasicCharactersData(List<int> charactersId);
|
||||
Task<IEnumerable<CharacterForLoginViewModel>> GetUserLoginCharacters(int userId);
|
||||
}
|
||||
}
|
||||
|
@ -40,14 +40,14 @@ namespace SessionCompanion.Services.Services
|
||||
/// <summary>
|
||||
/// Funkcja zwraca podstawowy widok postaci na podstawie ich id
|
||||
/// </summary>
|
||||
/// <param name="characterId">identyfikator postaci</param>
|
||||
/// <returns>Podstawowy widok danej postaci</returns>
|
||||
public async Task<CharacterBasicStatsViewModel> GetBasicCharacterData(int characterId)
|
||||
/// <param name="charactersId">Lista identyfikatorów postaci</param>
|
||||
/// <returns>Podstawowy widok podanych postaci</returns>
|
||||
public async Task<IEnumerable<CharacterBasicStatsViewModel>> GetBasicCharactersData(List<int> charactersId)
|
||||
{
|
||||
var characters = await Repository.Get(c => c.Id == characterId)
|
||||
.Include(x => x.Biography)
|
||||
.Include(x => x.Statistics).ToListAsync();
|
||||
var result = Mapper.Map<CharacterBasicStatsViewModel>(characters);
|
||||
var characters = await Repository.Get(c => charactersId.Contains(c.Id))
|
||||
.Include(x => x.Biography)
|
||||
.Include(x => x.Statistics).ToListAsync();
|
||||
var result = Mapper.Map<IEnumerable<CharacterBasicStatsViewModel>>(characters);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -71,13 +71,10 @@ namespace SessionCompanion.Controllers
|
||||
[HttpGet("loggedCharacters")]
|
||||
public async Task<Either<List<CharacterBasicStatsViewModel>, ErrorResponse>> GetLoggedUsersCharacters()
|
||||
{
|
||||
List<CharacterBasicStatsViewModel> characters = new List<CharacterBasicStatsViewModel>();
|
||||
var connectedCharacters = _sessionHubData.ConnectedCharacters_Prop;
|
||||
var characters = await _service.GetBasicCharactersData(connectedCharacters.Values.ToList());
|
||||
|
||||
foreach (var characterId in connectedCharacters.Values)
|
||||
characters.Add(await _service.GetBasicCharacterData(characterId));
|
||||
|
||||
return characters;
|
||||
return characters.ToList();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user