session-companion/SessionCompanion/SessionCompanion.Services/Services/CharacterWeaponService.cs

35 lines
1.3 KiB
C#
Raw Normal View History

2020-12-27 19:47:13 +01:00
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;
2020-12-27 19:47:13 +01:00
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;
}
2020-12-27 19:47:13 +01:00
}
}