public async Task <ResultListDto> GetBranchesAsync(BranchFilterDto branchFilterDto) { if (branchFilterDto != null && branchFilterDto.UserBranchDto != null) { UserBranches userBranches = new UserBranches(); userBranches = _mapper.Map <UserBranches>(branchFilterDto.UserBranchDto); if (branchFilterDto.Branches == null || branchFilterDto.Branches.Count == 0) { branchFilterDto.Branches = await _branchService.GetBranchesForFiltersAsync(userBranches); } } var branchFilter = _mapper.Map <BranchFilter>(branchFilterDto); var branchList = await _branchService.GetBranchesAsync(branchFilter); var branchDtoList = _mapper.Map <IEnumerable <BranchDto> >(branchList.Results); ResultListDto finalResult = new ResultListDto() { MaxPageRows = branchList.MaxPageRows, TotalRows = branchList.TotalRows, Results = branchDtoList }; return(finalResult); }