public async Task <IActionResult> SearchLocationsAsync(SearchLocationsViewModel searchModel) { try { LocationSearchDto searchDto = new LocationSearchDto { Title = searchModel.Title }; var locations = await locationService.SearchLocationsAsync(searchDto); LocationsListViewModel viewModel = new LocationsListViewModel() { Locations = locations }; return(View("Views/Location/LocationsList.cshtml", viewModel)); } catch (Exception ex) { ErrorViewModel errorModel = new ErrorViewModel(); errorModel.ErrorMessage = ex.Message.ToString(); return(View("Views/Shared/Error.cshtml", errorModel)); } }
public async Task <List <LocationDto> > SearchLocatonsAsync(LocationSearchDto searchDto) { var locations = await dbContext.Location .Where(l => (searchDto.Title == null) || ((searchDto.Title != null) && l.Title == searchDto.Title)) .ToListAsync(); var locationsDtos = locations.Select(l => mapper.Map <LocationDto>(l)).ToList(); return(locationsDtos); }
public async Task <List <LocationDto> > SearchLocationsAsync(LocationSearchDto searchDto) { var locations = await litigationPlannerUnitOfWork.LocationRepository.SearchLocatonsAsync(searchDto); return(locations); }