public SaveTravellerRs SaveTraveller(string sessionId, string authenticationId, Traveller traveller) { var response = new SaveTravellerRs { IsSuccess = true }; try { IAuthenticationProvider authProvider = AuthenticationProviderFactory.GetAuthenticationProvider(); if (authProvider.Validate(authenticationId)) { string accountId = authProvider.GetAccountId(authenticationId); if (!string.IsNullOrEmpty(accountId)) { traveller.AccountId = accountId; IAccountProvider accountProvider = AccountProviderFactory.GetAccountProvider(); string errorMessage = null; Core.Model.Traveller updatedTraveller = accountProvider.SaveOrUpdateTraveller(traveller.ToModel(), out errorMessage); if (updatedTraveller == null || !string.IsNullOrEmpty(errorMessage)) { response.IsSuccess = false; response.ErrorMessage = errorMessage; } else { response.Traveller = updatedTraveller.ToDataContract(); } } else { response.IsSuccess = false; response.ErrorMessage = "Account not found! Please SignIn or SingUp"; } } } catch (Exception ex) { Logger.LogException(ex, Source, "SaveTraveller", Severity.Major); response.IsSuccess = false; response.ErrorMessage = ex.ToString(); } return response; }
public void SaveTraveller() { Traveller tav = new Traveller() { AccountId = TestUserAccount.AccountId, TravellerId = "0", FirstName = "Test", LastName = "Traveller", Title = "Mr.", DateOfBirth = DateTime.Now.AddYears(-27).ToString("MM/dd/yyyy"), Gender = "Male" }; SaveTravellerRs response = LoginService.SaveTraveller(_sessionId, TestUserAccount.AuthenticationId, tav); Assert.IsNotNull(response, "Save traveller response returns not successful"); Assert.IsTrue(response.IsSuccess, "Save traveller failed"); }
public SaveTravellerRs SaveTraveller(string sessionId, string authenticationId, Traveller traveller) { using (new ApplicationContextScope(new ApplicationContext())) { ApplicationContext.SetSessionId(sessionId); try { var channelFactory = new WebChannelFactory<ILoginServiceRest>(Configuration.LoginServiceConfigurationName); ILoginServiceRest channel = channelFactory.CreateChannel(); if (channel is IContextChannel) using (new OperationContextScope(channel as IContextChannel)) { WebOperationContext.Current.OutgoingRequest.Headers.Add("X-MethodName", "SaveTraveller"); return channel.SaveTraveller(sessionId, authenticationId, traveller); } } catch (Exception exception) { Logger.LogException(exception, Source, "SaveTraveller", Severity.Major); } } return null; }