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>
|
public interface ICharacterService : IServiceBase<CharacterViewModel, Character>
|
||||||
{
|
{
|
||||||
|
Task<IEnumerable<CharacterBasicStatsViewModel>> GetBasicCharactersData(List<int> charactersId);
|
||||||
Task<IEnumerable<CharacterForLoginViewModel>> GetUserLoginCharacters(int userId);
|
Task<IEnumerable<CharacterForLoginViewModel>> GetUserLoginCharacters(int userId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,5 +37,19 @@ namespace SessionCompanion.Services.Services
|
|||||||
return result;
|
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['username'],
|
||||||
this.signInFormGroup.get('signIn').value['password']).subscribe(
|
this.signInFormGroup.get('signIn').value['password']).subscribe(
|
||||||
(success) => {
|
(success) => {
|
||||||
this.router.navigate(['player']);
|
this.router.navigate(['select-character']);
|
||||||
},
|
},
|
||||||
(error: ErrorResponse | HttpErrorResponse) => {
|
(error: ErrorResponse | HttpErrorResponse) => {
|
||||||
if (error instanceof HttpErrorResponse) {
|
if (error instanceof HttpErrorResponse) {
|
||||||
|
@ -7,6 +7,7 @@ using SessionCompanion.ViewModels.CharacterViewModels;
|
|||||||
|
|
||||||
namespace SessionCompanion.Controllers
|
namespace SessionCompanion.Controllers
|
||||||
{
|
{
|
||||||
|
using SessionCompanion.Hubs;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@ -16,10 +17,12 @@ namespace SessionCompanion.Controllers
|
|||||||
public class CharacterController : Controller
|
public class CharacterController : Controller
|
||||||
{
|
{
|
||||||
private readonly ICharacterService _service;
|
private readonly ICharacterService _service;
|
||||||
|
private readonly SessionHubData _sessionHubData;
|
||||||
|
|
||||||
public CharacterController(ICharacterService service)
|
public CharacterController(ICharacterService service)
|
||||||
{
|
{
|
||||||
this._service = service;
|
this._service = service;
|
||||||
|
this._sessionHubData = new SessionHubData();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -44,7 +47,7 @@ namespace SessionCompanion.Controllers
|
|||||||
/// Metoda zwraca listę postaci przypisanych do danego użytkownika
|
/// Metoda zwraca listę postaci przypisanych do danego użytkownika
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="userId"> Identyfikator użytkownika </param>
|
/// <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")]
|
[HttpGet("userCharactersList")]
|
||||||
public async Task<Either<List<CharacterForLoginViewModel>, ErrorResponse>> GetCharacterListForUser([Required] int userId)
|
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"
|
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>
|
/// <summary>
|
||||||
/// Zwraca lub ustawia listę zalogowanych graczy
|
/// Zwraca lub ustawia listę zalogowanych postaci
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Dictionary<string, int> ConnectedCharacters_Prop
|
public Dictionary<string, int> ConnectedCharacters_Prop
|
||||||
{
|
{
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
{
|
{
|
||||||
"iisSettings": {
|
"iisSettings": {
|
||||||
"windowsAuthentication": false,
|
"windowsAuthentication": false,
|
||||||
"anonymousAuthentication": true,
|
"anonymousAuthentication": true,
|
||||||
@ -18,10 +18,10 @@
|
|||||||
"SessionCompanion": {
|
"SessionCompanion": {
|
||||||
"commandName": "Project",
|
"commandName": "Project",
|
||||||
"launchBrowser": true,
|
"launchBrowser": true,
|
||||||
"applicationUrl": "https://localhost:5001;http://localhost:5000",
|
|
||||||
"environmentVariables": {
|
"environmentVariables": {
|
||||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
}
|
},
|
||||||
|
"applicationUrl": "https://localhost:5001;http://localhost:5000"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -16,7 +16,13 @@
|
|||||||
Metoda zwraca listę postaci przypisanych do danego użytkownika
|
Metoda zwraca listę postaci przypisanych do danego użytkownika
|
||||||
</summary>
|
</summary>
|
||||||
<param name="userId"> Identyfikator użytkownika </param>
|
<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>
|
||||||
<member name="M:SessionCompanion.Controllers.UserController.Login(System.String,System.String)">
|
<member name="M:SessionCompanion.Controllers.UserController.Login(System.String,System.String)">
|
||||||
<summary>
|
<summary>
|
||||||
@ -88,7 +94,7 @@
|
|||||||
</member>
|
</member>
|
||||||
<member name="P:SessionCompanion.Hubs.SessionHubData.ConnectedCharacters_Prop">
|
<member name="P:SessionCompanion.Hubs.SessionHubData.ConnectedCharacters_Prop">
|
||||||
<summary>
|
<summary>
|
||||||
Zwraca lub ustawia listę zalogowanych graczy
|
Zwraca lub ustawia listę zalogowanych postaci
|
||||||
</summary>
|
</summary>
|
||||||
</member>
|
</member>
|
||||||
</members>
|
</members>
|
||||||
|
Loading…
Reference in New Issue
Block a user