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

34 lines
1.5 KiB
C#

namespace SessionCompanion.Services.Services
{
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using AutoMapper;
using Microsoft.EntityFrameworkCore;
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;
}
}
}