You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
60 lines
1.7 KiB
60 lines
1.7 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using DTO;
|
|
using Entity;
|
|
using Shared;
|
|
using Dto2Entities;
|
|
|
|
namespace ServicesApi
|
|
{
|
|
public class CharacterService : ICharacterService<CharacterDTO>
|
|
{
|
|
private ICharacterService<Character> characterService;
|
|
|
|
public CharacterService(ICharacterService<Character> character)
|
|
{
|
|
characterService = character;
|
|
}
|
|
|
|
|
|
public async Task AddCharacter(CharacterDTO character)
|
|
{
|
|
await characterService.AddCharacter(character.ToEntity());
|
|
}
|
|
|
|
public async Task<PaginationResult<CharacterDTO>> GetAll()
|
|
{
|
|
var characters = characterService.GetAll().Result.items;
|
|
return new PaginationResult<CharacterDTO>(characters.Count(), 0, 10, characters.ToDto());
|
|
}
|
|
|
|
public async Task<CharacterDTO> GetCharById(int id)
|
|
{
|
|
return characterService.GetCharById(id).Result.ToDto();
|
|
}
|
|
|
|
public async Task<CharacterDTO> GetCharByName(string name)
|
|
{
|
|
return characterService.GetCharByName(name).Result.ToDto();
|
|
}
|
|
|
|
public async Task<int> GetLastCharId()
|
|
{
|
|
return await characterService.GetLastCharId();
|
|
}
|
|
|
|
public async Task RemoveCharacter(int id)
|
|
{
|
|
await characterService.RemoveCharacter(id);
|
|
}
|
|
|
|
public async Task UpdateCharacter(int id, CharacterDTO character)
|
|
{
|
|
await characterService.UpdateCharacter(id, character.ToEntity());
|
|
}
|
|
}
|
|
}
|