Пример #1
0
        public async Task <DirectoryDto> GetAsync(int id)
        {
            var directory = await _directoryRepository.GetAsync(id);

            if (directory == null)
            {
                return(null);
            }

            return(_mapper.Map <DirectoryDto>(directory));
        }
        public static async Task <Directory> GetOrFailAsync(this IDirectoryRepository repository, int id)
        {
            var directory = await repository.GetAsync(id);

            if (directory == null)
            {
                throw new Exception($"Directory with id '{id}' does not exist.");
            }

            return(directory);
        }