using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Volo.Abp.Application.Dtos; using Volo.Abp.TestApp.Domain; using Volo.Abp.Domain.Repositories; using Volo.Abp.Application.Services; using Volo.Abp.TestApp.Application.Dto; namespace Volo.Abp.TestApp.Application { public class PeopleAppService : AsyncCrudAppService, IPeopleAppService { public PeopleAppService(IRepository repository) : base(repository) { } public async Task> GetPhones(Guid id, GetPersonPhonesFilter filter) { var phones = (await GetEntityByIdAsync(id)).Phones .WhereIf(filter.Type.HasValue, p => p.Type == filter.Type) .ToList(); return new ListResultDto( ObjectMapper.Map, List>(phones) ); } public async Task AddPhone(Guid id, PhoneDto phoneDto) { var person = await GetEntityByIdAsync(id); var phone = new Phone(person.Id, phoneDto.Number, phoneDto.Type); person.Phones.Add(phone); return ObjectMapper.Map(phone); } public async Task RemovePhone(Guid id, string number) { var person = await GetEntityByIdAsync(id); person.Phones.RemoveAll(p => p.Number == number); } public Task GetWithComplexType(GetWithComplexTypeInput input) { return Task.FromResult(input); } } }