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