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

34 lines
1.5 KiB
C#
Raw Normal View History

2020-12-27 19:47:13 +01:00
namespace SessionCompanion.Services.Services
{
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
2020-12-27 19:47:13 +01:00
using AutoMapper;
using Microsoft.EntityFrameworkCore;
2020-12-27 19:47:13 +01:00
using SessionCompanion.Database.Repositories.Base;
using SessionCompanion.Database.Tables;
using SessionCompanion.Services.Base;
using SessionCompanion.Services.Interfaces;
using SessionCompanion.ViewModels.CharacterOtherEquipmentViewModels;
public class CharacterOtherEquipmentService : ServiceBase<CharacterOtherEquipmentViewModel, CharacterOtherEquipment>, ICharacterOtherEquipmentService
{
public CharacterOtherEquipmentService(IMapper mapper, IRepository<CharacterOtherEquipment> repository) : base(mapper, repository)
{ }
/// <summary>
/// Metoda pobiera listę pozostałego ekwipunku konkretnej postaci
/// </summary>
/// <param name="characterId"> Id postaci </param>
/// <returns> Lista pozostałego ekwpinuku posiadanego przez postać </returns>
public async Task<List<CharacterOtherEquipmentWithDetailsViewModel>> GetCharacterOtherEquipmentList(int characterId)
{
var characterWeapons = await Repository.Get().Where(a => a.CharacterId.Equals(characterId)).Include(a => a.OtherEquipment).ToListAsync();
var result = Mapper.Map<List<CharacterOtherEquipmentWithDetailsViewModel>>(characterWeapons);
return result;
}
2020-12-27 19:47:13 +01:00
}
}