public async Task <IActionResult> GetMasterlists() { try { var disciplineResources = await disciplinesRepository.GetAllDisciplinesWithSkills(); if (disciplineResources == null || !disciplineResources.Any()) { var error = new NotFoundException("No disciplines data found"); return(StatusCode(StatusCodes.Status404NotFound, new CustomException <NotFoundException>(error).GetException())); } var disciplines = MapDisciplines(disciplineResources); var locationResources = await locationsRepository.GetAllLocationsGroupByProvince(); if (locationResources == null || !locationResources.Any()) { var error = new NotFoundException("No locations data found"); return(StatusCode(StatusCodes.Status404NotFound, new CustomException <NotFoundException>(error).GetException())); } var locations = MapLocations(locationResources); var yearsOfExp = await resourceDisciplineRepository.GetAllYearsOfExp(); if (yearsOfExp == null || !yearsOfExp.Any()) { var error = new NotFoundException("No yearsOfExp data found"); return(StatusCode(StatusCodes.Status404NotFound, new CustomException <NotFoundException>(error).GetException())); } var resource = new MasterResource { Disciplines = disciplines, Locations = locations, YearsOfExp = yearsOfExp }; var response = new OkResponse <MasterResource>(resource, "Everything is good"); return(StatusCode(StatusCodes.Status200OK, response)); } catch (Exception err) { var errMessage = $"Source: {err.Source}\n Message: {err.Message}\n StackTrace: {err.StackTrace}\n"; if (err is SqlException) { var error = new InternalServerException(errMessage); return(StatusCode(StatusCodes.Status500InternalServerError, new CustomException <InternalServerException>(error).GetException())); } else { var error = new BadRequestException(errMessage); return(StatusCode(StatusCodes.Status400BadRequest, new CustomException <BadRequestException>(error).GetException())); } } }