public async Task <InstanceSettingsDto> GetLastEntityByInstanceIdAsync(Guid clientId) { var entity = await _repository.GetLastEntityByInstanceIdAsync(clientId); if (entity == null) { throw new NotFoundException(); } return(_mapper.Map <InstanceSettings, InstanceSettingsDto>(entity)); }