SES-69 Added controllers and comments #17

Merged
s426135 merged 2 commits from SES-69 into master 2020-12-06 15:29:13 +01:00
9 changed files with 152 additions and 20 deletions

View File

@ -1,14 +1,25 @@
using System; namespace SessionCompanion.ViewModels.CharacterViewModels
using System.Collections.Generic;
using System.Text;
namespace SessionCompanion.ViewModels.CharacterViewModels
{ {
public class CharacterBasicStatsViewModel public class CharacterBasicStatsViewModel
{ {
/// <summary>
/// Identyfikator psotaci
/// </summary>
public int Id { get; set; } public int Id { get; set; }
/// <summary>
/// Nazwa postaci
/// </summary>
public string Name { get; set; } public string Name { get; set; }
/// <summary>
/// Poziom postaci
/// </summary>
public int Level { get; set; } public int Level { get; set; }
/// <summary>
/// Aktualna ilość życia postaci
/// </summary>
public int CurrentHealthPoints { get; set; } public int CurrentHealthPoints { get; set; }
} }
} }

View File

@ -1,16 +1,30 @@
using System; namespace SessionCompanion.ViewModels.CharacterViewModels
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Text;
namespace SessionCompanion.ViewModels.CharacterViewModels
{ {
public class CharacterForLoginViewModel public class CharacterForLoginViewModel
{ {
/// <summary>
/// Identyfikator psotaci
/// </summary>
public int Id { get; set; } public int Id { get; set; }
/// <summary>
/// Id użytkownika do którego przypisana jest postać
/// </summary>
public int UserId { get; set; } public int UserId { get; set; }
/// <summary>
/// Nazwa postaci
/// </summary>
public string Name { get; set; } public string Name { get; set; }
/// <summary>
/// Nazwa klasy postaci
/// </summary>
public string ClassName { get; set; } public string ClassName { get; set; }
/// <summary>
/// Poziom postaci
/// </summary>
public int Level { get; set; } public int Level { get; set; }
} }
} }

View File

@ -1,13 +1,15 @@
using System; namespace SessionCompanion.ViewModels.CharacterViewModels
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Text;
namespace SessionCompanion.ViewModels.CharacterViewModels
{ {
public class CharacterViewModel public class CharacterViewModel
{ {
/// <summary>
/// Identyfikator psotaci
/// </summary>
public int Id { get; set; } public int Id { get; set; }
/// <summary>
/// Id użytkownika do którego przypisana jest postać
/// </summary>
public int UserId { get; set; } public int UserId { get; set; }
} }
} }

View File

@ -0,0 +1,18 @@
using Microsoft.AspNetCore.Mvc;
using SessionCompanion.Services.Interfaces;
namespace SessionCompanion.Controllers
{
[Route("api/background")]
[ApiController]
public class BackgroundController : Controller
{
private readonly IBackgroundService _service;
public BackgroundController(IBackgroundService service)
{
_service = service;
}
}
}

View File

@ -0,0 +1,17 @@
using Microsoft.AspNetCore.Mvc;
using SessionCompanion.Services.Interfaces;
namespace SessionCompanion.Controllers
{
[Route("api/biography")]
[ApiController]
public class BiographyController : Controller
{
private readonly IBiographyService _service;
public BiographyController(IBiographyService service)
{
_service = service;
}
}
}

View File

@ -0,0 +1,33 @@
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using SessionCompanion.Services.Interfaces;
namespace SessionCompanion.Controllers
{
using SessionCompanion.ViewModels.CharacterViewModels;
[Route("api/character")]
[ApiController]
public class CharacterController : Controller
{
private readonly ICharacterService _service;
public CharacterController(ICharacterService service)
{
this._service = service;
}
/// <summary>
/// Metoda zwraca postać ze wskazanym identyfikatorem
/// </summary>
/// <param name="id">Identyfikator postaci</param>
/// <returns>ViewModel Postaci</returns>
[HttpGet("{id}")]
public async Task<CharacterViewModel> Get(int id)
{
return await _service.Get(id);
}
}
}

View File

@ -0,0 +1,17 @@
using Microsoft.AspNetCore.Mvc;
using SessionCompanion.Services.Interfaces;
namespace SessionCompanion.Controllers
{
[Route("api/statistic")]
[ApiController]
public class StatisticController : Controller
{
private readonly IStatisticsService _service;
public StatisticController(IStatisticsService service)
{
this._service = service;
}
}
}

View File

@ -0,0 +1,17 @@
using Microsoft.AspNetCore.Mvc;
using SessionCompanion.Services.Interfaces;
namespace SessionCompanion.Controllers
{
[Route("api/user")]
[ApiController]
public class UserController : Controller
{
private readonly IUserService _service;
public UserController(IUserService service)
{
this._service = service;
}
}
}

View File

@ -1,9 +1,9 @@
using Microsoft.AspNetCore.SignalR; using System;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNetCore.SignalR;
namespace SessionCompanion.Hubs namespace SessionCompanion.Hubs
{ {
public class SessionHub : Hub public class SessionHub : Hub
@ -23,7 +23,10 @@ namespace SessionCompanion.Hubs
ConnectedCharacters.Remove(Context.ConnectionId); ConnectedCharacters.Remove(Context.ConnectionId);
} }
else else
{
Groups.RemoveFromGroupAsync(Context.ConnectionId, "GameMaster"); Groups.RemoveFromGroupAsync(Context.ConnectionId, "GameMaster");
}
Clients.All.SendAsync("GoodBye", "Player has left the game"); Clients.All.SendAsync("GoodBye", "Player has left the game");
return base.OnDisconnectedAsync(exception); return base.OnDisconnectedAsync(exception);
} }