public async Task <AuthorModel> GetFilteredAuthorsAsync(FilterAuthorModel filterModel) { var responseModel = new AuthorModel(); if (filterModel == null) { responseModel.Errors.Add(Constants.Errors.InvalidData); return(responseModel); } var repositoryModel = _mapperHelper.Map <FilterAuthorModel, DataFilter.BaseFilterModel>(filterModel); if (repositoryModel == null) { responseModel.Errors.Add(Constants.Errors.OccuredProcessing); return(responseModel); } var authors = await _authorRepository.GetFilteredAuthorsAsync(repositoryModel); foreach (var author in authors.Collection) { var itemModel = _mapperHelper.Map <AuthorDataModel, AuthorModelItem>(author); if (itemModel == null) { responseModel.Errors.Add(Constants.Errors.OccuredProcessing); continue; } responseModel.Items.Add(itemModel); } responseModel.ItemsCount = authors.CollectionCount; return(responseModel); }
public async Task <IActionResult> GetAuthorsInPrintingEditionAsync([FromBody] FilterAuthorModel authorFilterModel) { var responseModel = await _authorService.GetFilteredAuthorsAsync(authorFilterModel); return(Ok(responseModel)); }
public async Task <IActionResult> GetAllAuthorsAsync([FromBody] FilterAuthorModel filterModel) { var response = await _authorService.GetAllAuthorsAsync(filterModel); return(Ok(response)); }