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
|
|
|
|
|
{
|
2021-01-12 12:46:50 +01:00
|
|
|
|
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)
|
|
|
|
|
{ }
|
2021-01-12 12:46:50 +01:00
|
|
|
|
|
|
|
|
|
/// <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
|
|
|
|
}
|
|
|
|
|
}
|