示例#1
0
        public async Task <IActionResult> GetPlaceCategories([FromBody] GetPlaceCategoryInputDto getinput)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }
            var result = await CategoryServise.GetPlaceCategory(getinput);

            return(Ok(result));
        }
        public async Task <List <GetPlaceCategoryOutputDto> > GetPlaceCategory(GetPlaceCategoryInputDto getinput)
        {
            await Findplace(getinput.PlaceName);

            var categories = TuristPlaceCategory.GetQuery()
                             .Include(tc => tc.TuristPlaces)
                             .Include(tc => tc.Categories)
                             .Where(tc => tc.TuristPlaces.Name == getinput.PlaceName)
                             .Select(tc => tc.Categories)
                             .Select(c => mapper.Map <GetPlaceCategoryOutputDto>(c))
                             .ToList();

            if (categories == null)
            {
                throw new KeyNotFoundException("Not found category for this place");
            }
            return(categories);
        }