public async Task GetAsync(Guid id){var author = await _authorRepository.GetAsync(id);return ObjectMapper.Map<Author, AuthorDto>(author);} [Authorize(BookStorePermissions.Authors.Create)]public async Task CreateAsync(CreateAuthorDto input){var author = await _authorManager.CreateAsync(input.Name, input.BirthDate, input.ShortBio);await _authorRepository.InsertAsync(author);return ObjectMapper.Map<Author, AuthorDto>(author);} public async Task<PagedResultDto> GetListAsync(GetAuthorListDto input){if (input.Sorting.IsNullOrWhiteSpace()){input.Sorting = nameof(Author.Name);}var authors = await _authorRepository.GetListAsync(input.SkipCount, input.MaxResultCount, input.Sorting, input.Filter);var totalCount = input.Filter == null? await _authorRepository.CountAsync(): await _authorRepository.CountAsync(author => author.Name.Contains(input.Filter));return new PagedResultDto(totalCount, ObjectMapper.Map<List, List>(authors));}

Author API: CRUD Operations for Authors

原文地址: https://www.cveoy.top/t/topic/pYTV 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录