public async Task <List <HallDTO> > GetAllAsync(HttpRequest request) { // Get language from header StringValues language = LanguageConstants.LanguageDefault; request?.Headers?.TryGetValue("Accept-Language", out language); var halls = await _hallsRepository.GetAllAsync(); MapperConfiguration mapperConfiguration = null; MapperConfiguration mapperConfigurationPhoto = null; List <HallDTO> hallsDTO = new List <HallDTO>(); if (halls != null) { // Create mapping depending on language switch (language) { case LanguageConstants.LanguageRu: mapperConfiguration = HallsMappingConfigurations.GetAllRuConfiguration; mapperConfigurationPhoto = HallsMappingConfigurations.GetAllRuPhotoConfiguration; break; case LanguageConstants.LanguageEn: mapperConfiguration = HallsMappingConfigurations.GetAllEnConfiguration; mapperConfigurationPhoto = HallsMappingConfigurations.GetAllEnPhotoConfiguration; break; case LanguageConstants.LanguageBy: mapperConfiguration = HallsMappingConfigurations.GetAllByConfiguration; mapperConfigurationPhoto = HallsMappingConfigurations.GetAllByPhotoConfiguration; break; default: mapperConfiguration = HallsMappingConfigurations.GetAllEnConfiguration; mapperConfigurationPhoto = HallsMappingConfigurations.GetAllEnPhotoConfiguration; break; } } var mapper = new Mapper(mapperConfiguration); hallsDTO = mapper.Map <List <HallDTO> >(halls); mapper = new Mapper(mapperConfigurationPhoto); for (int i = 0; i < halls.Count; i++) { var photoInfoDTO = mapper.Map <PhotoInfoDTO>(halls[i].Photo); hallsDTO[i].Photo = photoInfoDTO; } return(hallsDTO); }
public async Task <List <HallViewModel> > GetAllAsync() { return(await _hallsRepository.GetAllAsync()); }