SES-118 Addes services
This commit is contained in:
parent
b53ece536b
commit
6ca10bd803
@ -1,6 +1,7 @@
|
|||||||
using SessionCompanion.Database.Tables;
|
using SessionCompanion.Database.Tables;
|
||||||
using SessionCompanion.Services.Base;
|
using SessionCompanion.Services.Base;
|
||||||
using SessionCompanion.ViewModels.CharacterViewModels;
|
using SessionCompanion.ViewModels.CharacterViewModels;
|
||||||
|
using SessionCompanion.ViewModels.UniversalModels;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
@ -12,6 +13,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<CharacterEveryStatViewModel> GetCharacterEveryStat(int characterId);
|
Task<List<UniversalStatisticViewModel>> GetCharacterStatistics(int characterId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,8 @@ using Microsoft.EntityFrameworkCore;
|
|||||||
using AutoMapper.QueryableExtensions;
|
using AutoMapper.QueryableExtensions;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
|
using SessionCompanion.ViewModels.UniversalModels;
|
||||||
|
using SessionCompanion.Services.Helpers;
|
||||||
|
|
||||||
namespace SessionCompanion.Services.Services
|
namespace SessionCompanion.Services.Services
|
||||||
{
|
{
|
||||||
@ -68,5 +70,31 @@ namespace SessionCompanion.Services.Services
|
|||||||
var result = Mapper.Map<CharacterEveryStatViewModel>(character);
|
var result = Mapper.Map<CharacterEveryStatViewModel>(character);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Funkcja zwraca listę, zawierającą statystyki danej postaci
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="characterId"></param>
|
||||||
|
/// <returns>lista zawierającą statystyki danej postaci</returns>
|
||||||
|
public async Task<List<UniversalStatisticViewModel>> GetCharacterStatistics(int characterId)
|
||||||
|
{
|
||||||
|
List<UniversalStatisticViewModel> statistics = new List<UniversalStatisticViewModel>();
|
||||||
|
var character = await Repository.Get(c => c.Id.Equals(characterId))
|
||||||
|
.Include(x => x.Intelligence)
|
||||||
|
.Include(x => x.Strength)
|
||||||
|
.Include(x => x.Wisdom)
|
||||||
|
.Include(x => x.Charisma)
|
||||||
|
.Include(x => x.Constitution)
|
||||||
|
.Include(x => x.Dexterity)
|
||||||
|
.SingleAsync();
|
||||||
|
|
||||||
|
statistics.Add(CustomMappings.MapCharisma(character.Charisma));
|
||||||
|
statistics.Add(CustomMappings.MapDexterity(character.Dexterity));
|
||||||
|
statistics.Add(CustomMappings.MapConstitution(character.Constitution));
|
||||||
|
statistics.Add(CustomMappings.MapIntelligence(character.Intelligence));
|
||||||
|
statistics.Add(CustomMappings.MapStrength(character.Strength));
|
||||||
|
statistics.Add(CustomMappings.MapWisdom(character.Wisdom));
|
||||||
|
|
||||||
|
return statistics;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user