SES-134 Add service to subtract HP
This commit is contained in:
parent
136a68bda4
commit
b588292daf
@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user