public UmbracoLatchResponse Pair(string token, int userId) { var application = GetApplication(); var latch = new Latch(application.ApplicationId, application.Secret); var response = latch.Pair(token); if (response.Error != null) { var errorMessage = GetPairingResponseMessage("error" + response.Error.Code); return(new UmbracoLatchResponse(false, errorMessage)); } if (response.Data == null || !response.Data.ContainsKey("accountId")) { var errorMessage = GetPairingResponseMessage("pairError"); return(new UmbracoLatchResponse(false, errorMessage)); } var pairedAccount = new LatchPairedAccount { UserId = userId, AccountId = response.Data["accountId"] as string }; latchRepo.AddPairedAccount(pairedAccount); var successMessage = GetPairingResponseMessage("pairSuccess"); return(new UmbracoLatchResponse(true, successMessage)); }
public static LatchPairedAccountDto ToDto(this LatchPairedAccount pairedAccount) { var dto = new LatchPairedAccountDto(); if (pairedAccount != null) { dto.AccountId = pairedAccount.AccountId; } return(dto); }