Merge pull request 'SES-105 list of logged charcters' (#36) from SES-105 into dev
Reviewed-on: #36
This commit is contained in:
commit
070cafed58
@ -10,6 +10,7 @@ namespace SessionCompanion.Services.Interfaces
|
||||
{
|
||||
public interface ICharacterService : IServiceBase<CharacterViewModel, Character>
|
||||
{
|
||||
Task<IEnumerable<CharacterBasicStatsViewModel>> GetBasicCharactersData(List<int> charactersId);
|
||||
Task<IEnumerable<CharacterForLoginViewModel>> GetUserLoginCharacters(int userId);
|
||||
}
|
||||
}
|
||||
|
@ -37,5 +37,19 @@ namespace SessionCompanion.Services.Services
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Funkcja zwraca podstawowy widok postaci na podstawie ich id
|
||||
/// </summary>
|
||||
/// <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 => charactersId.Contains(c.Id))
|
||||
.Include(x => x.Biography)
|
||||
.Include(x => x.Statistics).ToListAsync();
|
||||
var result = Mapper.Map<IEnumerable<CharacterBasicStatsViewModel>>(characters);
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ export class SignInComponent implements OnDestroy {
|
||||
this.signInFormGroup.get('signIn').value['username'],
|
||||
this.signInFormGroup.get('signIn').value['password']).subscribe(
|
||||
(success) => {
|
||||
this.router.navigate(['player']);
|
||||
this.router.navigate(['select-character']);
|
||||
},
|
||||
(error: ErrorResponse | HttpErrorResponse) => {
|
||||
if (error instanceof HttpErrorResponse) {
|
||||
|
@ -7,6 +7,7 @@ using SessionCompanion.ViewModels.CharacterViewModels;
|
||||
|
||||
namespace SessionCompanion.Controllers
|
||||
{
|
||||
using SessionCompanion.Hubs;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
@ -16,10 +17,12 @@ namespace SessionCompanion.Controllers
|
||||
public class CharacterController : Controller
|
||||
{
|
||||
private readonly ICharacterService _service;
|
||||
private readonly SessionHubData _sessionHubData;
|
||||
|
||||
public CharacterController(ICharacterService service)
|
||||
{
|
||||
this._service = service;
|
||||
this._sessionHubData = new SessionHubData();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -44,7 +47,7 @@ namespace SessionCompanion.Controllers
|
||||
/// Metoda zwraca listę postaci przypisanych do danego użytkownika
|
||||
/// </summary>
|
||||
/// <param name="userId"> Identyfikator użytkownika </param>
|
||||
/// <returns> Lista postać lub wiadomość błędu </returns>
|
||||
/// <returns> Lista postaci lub wiadomość błędu </returns>
|
||||
[HttpGet("userCharactersList")]
|
||||
public async Task<Either<List<CharacterForLoginViewModel>, ErrorResponse>> GetCharacterListForUser([Required] int userId)
|
||||
{
|
||||
@ -61,5 +64,17 @@ namespace SessionCompanion.Controllers
|
||||
Message = "No characters with given user id"
|
||||
};
|
||||
}
|
||||
/// <summary>
|
||||
/// Metoda zwraca listę postaci przypisanych do danego użytkownika
|
||||
/// </summary>
|
||||
/// <returns> Lista zalogowanych postaci lub wiadomość błędu </returns>
|
||||
[HttpGet("loggedCharacters")]
|
||||
public async Task<Either<List<CharacterBasicStatsViewModel>, ErrorResponse>> GetLoggedUsersCharacters()
|
||||
{
|
||||
var connectedCharacters = _sessionHubData.ConnectedCharacters_Prop;
|
||||
var characters = await _service.GetBasicCharactersData(connectedCharacters.Values.ToList());
|
||||
|
||||
return characters.ToList();
|
||||
}
|
||||
}
|
||||
}
|
@ -34,7 +34,7 @@ namespace SessionCompanion.Hubs
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Zwraca lub ustawia listę zalogowanych graczy
|
||||
/// Zwraca lub ustawia listę zalogowanych postaci
|
||||
/// </summary>
|
||||
public Dictionary<string, int> ConnectedCharacters_Prop
|
||||
{
|
||||
|
@ -1,4 +1,4 @@
|
||||
{
|
||||
{
|
||||
"iisSettings": {
|
||||
"windowsAuthentication": false,
|
||||
"anonymousAuthentication": true,
|
||||
@ -18,10 +18,10 @@
|
||||
"SessionCompanion": {
|
||||
"commandName": "Project",
|
||||
"launchBrowser": true,
|
||||
"applicationUrl": "https://localhost:5001;http://localhost:5000",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
},
|
||||
"applicationUrl": "https://localhost:5001;http://localhost:5000"
|
||||
}
|
||||
}
|
||||
}
|
@ -16,7 +16,13 @@
|
||||
Metoda zwraca listę postaci przypisanych do danego użytkownika
|
||||
</summary>
|
||||
<param name="userId"> Identyfikator użytkownika </param>
|
||||
<returns> Lista postać lub wiadomość błędu </returns>
|
||||
<returns> Lista postaci lub wiadomość błędu </returns>
|
||||
</member>
|
||||
<member name="M:SessionCompanion.Controllers.CharacterController.GetLoggedUsersCharacters">
|
||||
<summary>
|
||||
Metoda zwraca listę postaci przypisanych do danego użytkownika
|
||||
</summary>
|
||||
<returns> Lista zalogowanych postaci lub wiadomość błędu </returns>
|
||||
</member>
|
||||
<member name="M:SessionCompanion.Controllers.UserController.Login(System.String,System.String)">
|
||||
<summary>
|
||||
@ -88,7 +94,7 @@
|
||||
</member>
|
||||
<member name="P:SessionCompanion.Hubs.SessionHubData.ConnectedCharacters_Prop">
|
||||
<summary>
|
||||
Zwraca lub ustawia listę zalogowanych graczy
|
||||
Zwraca lub ustawia listę zalogowanych postaci
|
||||
</summary>
|
||||
</member>
|
||||
</members>
|
||||
|
Loading…
Reference in New Issue
Block a user