public async Task <VerificationResult> VerifyInterpreter(string interpreterId, int orderId, CompetenceAndSpecialistLevel competenceLevel, bool reVerify = false) { if (string.IsNullOrWhiteSpace(interpreterId)) { return(VerificationResult.NotFound); } try { var order = await _dbContext.Orders.GetOrderWithLanguageByOrderId(orderId); if (string.IsNullOrEmpty(order.Language.TellusName)) { return(VerificationResult.LanguageNotRegistered); } var response = await client.GetAsync($"{_tolkBaseOptions.Tellus.Uri}{interpreterId}"); string content = await response.Content.ReadAsStringAsync(); TellusInterpreterResponse information = JsonConvert.DeserializeObject <TellusInterpreterResponse>(content); return(CheckInterpreter(competenceLevel, order, information)); } catch (Exception e) { _logger.LogError(e, $"Failed to verify the interpreter against {_tolkBaseOptions.Tellus.Uri}" + (reVerify ? " for second time" : " for first time")); //try to verify once more if reVerify is false since it's probably most often connection problem/timeout return(!reVerify ? await VerifyInterpreter(interpreterId, orderId, competenceLevel, true) : VerificationResult.UnknownError); } }
private static VerificationResult CheckInterpreter(CompetenceAndSpecialistLevel competenceLevel, Order order, TellusInterpreterResponse information) { if (information.TotalMatching < 1) { return(VerificationResult.NotFound); } var interpreter = information.Result.First(); if (competenceLevel == CompetenceAndSpecialistLevel.EducatedInterpreter) { return(VerifyInterpreter(order.StartAt, interpreter.Educations.Where(c => c.Language == order.Language.TellusName))); } else { return(VerifyInterpreter(order.StartAt, interpreter.Competences.Where(c => c.Language == order.Language.TellusName && c.Competencelevel.Id == competenceLevel.GetTellusName()))); } }