35 lines
1.3 KiB
C#
35 lines
1.3 KiB
C#
using AutoMapper;
|
|
using SessionCompanion.Database.Repositories.Base;
|
|
using SessionCompanion.Database.Tables;
|
|
using SessionCompanion.Services.Base;
|
|
using SessionCompanion.Services.Interfaces;
|
|
using SessionCompanion.ViewModels.CharacterWeaponViewModels;
|
|
|
|
namespace SessionCompanion.Services.Services
|
|
{
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
public class CharacterWeaponService : ServiceBase<CharacterWeaponViewModel, CharacterWeapon>, ICharacterWeaponService
|
|
{
|
|
public CharacterWeaponService(IMapper mapper, IRepository<CharacterWeapon> repository) : base(mapper, repository)
|
|
{ }
|
|
|
|
/// <summary>
|
|
/// Metoda pobiera listę broni konkretnej postaci
|
|
/// </summary>
|
|
/// <param name="characterId"> Id postaci </param>
|
|
/// <returns> Lista broni posiadanych przez postać </returns>
|
|
public async Task<List<CharacterWeaponWithWeaponDetailsViewModel>> GetCharacterWeaponsList(int characterId)
|
|
{
|
|
var characterWeapons = await Repository.Get().Where(w => w.CharacterId.Equals(characterId)).Include(w => w.Weapon).ToListAsync();
|
|
|
|
var result = Mapper.Map<List<CharacterWeaponWithWeaponDetailsViewModel>>(characterWeapons);
|
|
return result;
|
|
}
|
|
}
|
|
}
|