SES-129 Merge
This commit is contained in:
commit
67cb189ef4
@ -14,5 +14,6 @@ namespace SessionCompanion.Services.Interfaces
|
|||||||
Task<IEnumerable<CharacterBasicStatsViewModel>> GetBasicCharactersData(List<int> charactersId);
|
Task<IEnumerable<CharacterBasicStatsViewModel>> GetBasicCharactersData(List<int> charactersId);
|
||||||
Task<IEnumerable<CharacterForLoginViewModel>> GetUserLoginCharacters(int userId);
|
Task<IEnumerable<CharacterForLoginViewModel>> GetUserLoginCharacters(int userId);
|
||||||
Task<List<UniversalStatisticViewModel>> GetCharacterStatistics(int characterId);
|
Task<List<UniversalStatisticViewModel>> GetCharacterStatistics(int characterId);
|
||||||
|
Task<CharacterBasicInfoViewModel> GetBasicCharacterbasicInfo(int characterId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,5 +10,6 @@ namespace SessionCompanion.Services.Interfaces
|
|||||||
{
|
{
|
||||||
public interface IStatisticsService : IServiceBase<StatisticsViewModel, Statistics>
|
public interface IStatisticsService : IServiceBase<StatisticsViewModel, Statistics>
|
||||||
{
|
{
|
||||||
|
Task SubtractHp(int characterId, int hpToSubtract);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,14 @@ namespace SessionCompanion.Services.Profiles
|
|||||||
.ForMember(vm => vm.CurrentHealthPoints, conf => conf.MapFrom(charact => charact.Statistics.CurrentHealthPoints))
|
.ForMember(vm => vm.CurrentHealthPoints, conf => conf.MapFrom(charact => charact.Statistics.CurrentHealthPoints))
|
||||||
.ForMember(vm => vm.Class, conf => conf.MapFrom(charact => charact.Biography.Class.Name)).ReverseMap();
|
.ForMember(vm => vm.Class, conf => conf.MapFrom(charact => charact.Biography.Class.Name)).ReverseMap();
|
||||||
|
|
||||||
|
CreateMap<Character, CharacterBasicInfoViewModel>()
|
||||||
|
.ForMember(vm => vm.Name, conf => conf.MapFrom(charact => charact.Biography.Name))
|
||||||
|
.ForMember(vm => vm.Level, conf => conf.MapFrom(charact => charact.Statistics.Level))
|
||||||
|
.ForMember(vm => vm.CurrentHealthPoints, conf => conf.MapFrom(charact => charact.Statistics.CurrentHealthPoints))
|
||||||
|
.ForMember(vm => vm.MaxHealthPoints, conf => conf.MapFrom(charact => charact.Statistics.HealthPoints))
|
||||||
|
.ForMember(vm => vm.Race, conf => conf.MapFrom(charact => charact.Biography.Race.Name))
|
||||||
|
.ForMember(vm => vm.Class, conf => conf.MapFrom(charact => charact.Biography.Class.Name)).ReverseMap();
|
||||||
|
|
||||||
CreateMap<Character, CharacterEveryStatViewModel>()
|
CreateMap<Character, CharacterEveryStatViewModel>()
|
||||||
.ForMember(vm => vm.CanDeception, conf => conf.MapFrom(charact => charact.Charisma.CanDeception))
|
.ForMember(vm => vm.CanDeception, conf => conf.MapFrom(charact => charact.Charisma.CanDeception))
|
||||||
.ForMember(vm => vm.CanIntimidation, conf => conf.MapFrom(charact => charact.Charisma.CanIntimidation))
|
.ForMember(vm => vm.CanIntimidation, conf => conf.MapFrom(charact => charact.Charisma.CanIntimidation))
|
||||||
|
@ -96,5 +96,20 @@ namespace SessionCompanion.Services.Services
|
|||||||
|
|
||||||
return statistics;
|
return statistics;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Funkcja zwraca podstawowy widok postaci na podstawie ich id
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="characterId">Lista identyfikatorów postaci</param>
|
||||||
|
/// <returns>Podstawowy widok podanych postaci</returns>
|
||||||
|
public async Task<CharacterBasicInfoViewModel> GetBasicCharacterbasicInfo(int characterId)
|
||||||
|
{
|
||||||
|
var character = await Repository.Get(c => c.Id.Equals(characterId))
|
||||||
|
.Include(x => x.Biography).ThenInclude(x => x.Class)
|
||||||
|
.Include(x => x.Biography).ThenInclude(x => x.Race)
|
||||||
|
.Include(x => x.Statistics).SingleAsync();
|
||||||
|
var result = Mapper.Map<CharacterBasicInfoViewModel>(character);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,5 +17,18 @@ namespace SessionCompanion.Services.Services
|
|||||||
{
|
{
|
||||||
public StatisticsService(IMapper mapper, IRepository<Statistics> repository) : base(mapper, repository)
|
public StatisticsService(IMapper mapper, IRepository<Statistics> repository) : base(mapper, repository)
|
||||||
{ }
|
{ }
|
||||||
|
/// <summary>
|
||||||
|
/// Method subtract hp from given character
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="characterId"></param>
|
||||||
|
/// <param name="hpToSubtract"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task SubtractHp(int characterId, int hpToSubtract)
|
||||||
|
{
|
||||||
|
var result = await Repository.Get(c => c.Id.Equals(characterId)).SingleAsync();
|
||||||
|
result.CurrentHealthPoints -= hpToSubtract;
|
||||||
|
await Repository.Update(result);
|
||||||
|
await Repository.Save();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,46 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace SessionCompanion.ViewModels.CharacterViewModels
|
||||||
|
{
|
||||||
|
public class CharacterBasicInfoViewModel
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Identyfikator postaci
|
||||||
|
/// </summary>
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Nazwa postaci
|
||||||
|
/// </summary>
|
||||||
|
public string Name { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Poziom postaci
|
||||||
|
/// </summary>
|
||||||
|
public int Level { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Aktualna ilość życia postaci
|
||||||
|
/// </summary>
|
||||||
|
public int CurrentHealthPoints { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Maksymalna ilość życia psotaci
|
||||||
|
/// </summary>
|
||||||
|
public int MaxHealthPoints { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Klasa postaci
|
||||||
|
/// </summary>
|
||||||
|
public string Class { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Rasa postaci
|
||||||
|
/// </summary>
|
||||||
|
public string Race{ get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -80,6 +80,41 @@
|
|||||||
Płeć postaci
|
Płeć postaci
|
||||||
</summary>
|
</summary>
|
||||||
</member>
|
</member>
|
||||||
|
<member name="P:SessionCompanion.ViewModels.CharacterViewModels.CharacterBasicInfoViewModel.Id">
|
||||||
|
<summary>
|
||||||
|
Identyfikator postaci
|
||||||
|
</summary>
|
||||||
|
</member>
|
||||||
|
<member name="P:SessionCompanion.ViewModels.CharacterViewModels.CharacterBasicInfoViewModel.Name">
|
||||||
|
<summary>
|
||||||
|
Nazwa postaci
|
||||||
|
</summary>
|
||||||
|
</member>
|
||||||
|
<member name="P:SessionCompanion.ViewModels.CharacterViewModels.CharacterBasicInfoViewModel.Level">
|
||||||
|
<summary>
|
||||||
|
Poziom postaci
|
||||||
|
</summary>
|
||||||
|
</member>
|
||||||
|
<member name="P:SessionCompanion.ViewModels.CharacterViewModels.CharacterBasicInfoViewModel.CurrentHealthPoints">
|
||||||
|
<summary>
|
||||||
|
Aktualna ilość życia postaci
|
||||||
|
</summary>
|
||||||
|
</member>
|
||||||
|
<member name="P:SessionCompanion.ViewModels.CharacterViewModels.CharacterBasicInfoViewModel.MaxHealthPoints">
|
||||||
|
<summary>
|
||||||
|
Maksymalna ilość życia psotaci
|
||||||
|
</summary>
|
||||||
|
</member>
|
||||||
|
<member name="P:SessionCompanion.ViewModels.CharacterViewModels.CharacterBasicInfoViewModel.Class">
|
||||||
|
<summary>
|
||||||
|
Klasa postaci
|
||||||
|
</summary>
|
||||||
|
</member>
|
||||||
|
<member name="P:SessionCompanion.ViewModels.CharacterViewModels.CharacterBasicInfoViewModel.Race">
|
||||||
|
<summary>
|
||||||
|
Rasa postaci
|
||||||
|
</summary>
|
||||||
|
</member>
|
||||||
<member name="P:SessionCompanion.ViewModels.CharacterViewModels.CharacterBasicStatsViewModel.Id">
|
<member name="P:SessionCompanion.ViewModels.CharacterViewModels.CharacterBasicStatsViewModel.Id">
|
||||||
<summary>
|
<summary>
|
||||||
Identyfikator postaci
|
Identyfikator postaci
|
||||||
|
@ -88,5 +88,22 @@ namespace SessionCompanion.Controllers
|
|||||||
var statistics = await _service.GetCharacterStatistics(characterId);
|
var statistics = await _service.GetCharacterStatistics(characterId);
|
||||||
return statistics;
|
return statistics;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Metoda zwraca podstawowe informacje dla danej postaci
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="characterId"></param>
|
||||||
|
/// <returns>Podstawowe informacje dla danej postaci</returns>
|
||||||
|
[HttpGet("characterBasicInfo")]
|
||||||
|
public async Task<Either<CharacterBasicInfoViewModel, ErrorResponse>> GetCharacterBasicInfo([Required] int characterId)
|
||||||
|
{
|
||||||
|
var info = await _service.GetBasicCharacterbasicInfo(characterId);
|
||||||
|
if (info is null)
|
||||||
|
return new ErrorResponse() {
|
||||||
|
Message = "No characters with given id",
|
||||||
|
StatusCode = 204
|
||||||
|
};
|
||||||
|
return info;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -36,6 +36,13 @@
|
|||||||
Metoda zwraca wszystkie dostępne zaklecia
|
Metoda zwraca wszystkie dostępne zaklecia
|
||||||
</summary>
|
</summary>
|
||||||
<returns>Lista wszystkich zaklęć w bazie danych</returns>
|
<returns>Lista wszystkich zaklęć w bazie danych</returns>
|
||||||
|
</member>
|
||||||
|
<member name="M:SessionCompanion.Controllers.CharacterController.GetCharacterBasicInfo(System.Int32)">
|
||||||
|
<summary>
|
||||||
|
Metoda zwraca podstawowe informacje dla danej postaci
|
||||||
|
</summary>
|
||||||
|
<param name="characterId"></param>
|
||||||
|
<returns>Podstawowe informacje dla danej postaci</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>
|
||||||
|
Loading…
Reference in New Issue
Block a user