public Traveller SaveOrUpdateTraveller(Traveller traveller, out string errorMessage) { errorMessage = string.Empty; if (traveller.TravellerId == 0) traveller.TravellerId = 1; return traveller; }
public void SaveOrUpdateTravellerTest() { IAuthenticationProvider authenticationProvider = new AuthenticationProvider(new HttpRuntimeCache()); ICaptchaProvider captchaProvider = new ReCaptchaProvider(); IEmailProvider emailProvider = new EmailProvider(); IMobileProvider mobileProvider = new MobileProvider(); var target = new AccountProvider(authenticationProvider, captchaProvider, emailProvider, mobileProvider); string errorMessage = null; Traveller tav = new Traveller() { AccountId = Convert.ToInt32(accountId), TravellerId = 1, FirstName = "Test", LastName = "Traveller", Title = "Mr.", DateOfBirth = DateTime.Now.AddYears(-27), Gender = "Male" }; Traveller updatedTraveller = target.SaveOrUpdateTraveller(tav, out errorMessage); Assert.IsTrue(updatedTraveller != null); Assert.IsTrue(string.IsNullOrEmpty(errorMessage)); }
public Traveller SaveOrUpdateTraveller(Traveller traveller, out string errorMessage) { errorMessage = string.Empty; IAccountDataProvider accountDataProvider = AccountDataProviderFactory.CreateAccountDataProvider(); return accountDataProvider.SaveOrUpdateTraveller(traveller, out errorMessage); }
internal static MySqlCommand BuildSaveOrUpdateTravellerCommand(MySqlConnection connection, Traveller traveller) { var cmd = new MySqlCommand("spSaveOrUpdateTraveller", connection) { CommandType = CommandType.StoredProcedure }; cmd.Parameters.Add(new MySqlParameter("inTravellerId", traveller.TravellerId)); cmd.Parameters.Add(new MySqlParameter("inAccountId", traveller.AccountId)); cmd.Parameters.Add(new MySqlParameter("inTitle", traveller.Title)); cmd.Parameters.Add(new MySqlParameter("inFirstName", traveller.FirstName)); cmd.Parameters.Add(new MySqlParameter("inLastName", traveller.LastName)); cmd.Parameters.Add(new MySqlParameter("inDateOfBirth", traveller.DateOfBirth)); cmd.Parameters.Add(new MySqlParameter("inGender", traveller.Gender)); cmd.Parameters.Add(new MySqlParameter("outTravellerId", MySqlDbType.Int32)); cmd.Parameters["outTravellerId"].Direction = ParameterDirection.Output; return cmd; }
public void SaveOrUpdateTravellerTest() { IAccountDataProvider target = _accountDataProvider; string errorMessage = null; Traveller tav = new Traveller() { AccountId = Convert.ToInt32(accountId), TravellerId = 1, FirstName = "Test", LastName = "Traveller", Title = "Mr.", DateOfBirth = DateTime.Now.AddYears(-27), Gender = "Male" }; Traveller updatedTraveller = target.SaveOrUpdateTraveller(tav, out errorMessage); Assert.IsTrue(updatedTraveller != null); Assert.IsTrue(string.IsNullOrEmpty(errorMessage)); }
private List<Traveller> GetTravellers(DataSet dataSet) { var travellers = new List<Traveller>(); if (dataSet != null && dataSet.Tables.Count > 0) { if (dataSet.Tables[0].Rows != null && dataSet.Tables[0].Rows.Count > 0) { foreach (DataRow row in dataSet.Tables[0].Rows) { try { var traveller = new Traveller() { AccountId = row["AccountId"].GetInt(), FirstName = row["FirstName"].GetString(), LastName = row["LastName"].GetString(), Title = row["Title"].GetString(), DateOfBirth = row["DateOfBirth"].GetDate(), TravellerId = row["TravellerId"].GetInt(), Gender = row["Gender"].GetString(), }; travellers.Add(traveller); } catch { } } return travellers.Count > 0 ? travellers : null; } } return null; }
public Traveller SaveOrUpdateTraveller(Traveller traveller, out string errorMessage) { try { errorMessage = string.Empty; var db = new MySqlDatabase(DbConfiguration.DatabaseWrite); int travellerId; db.ExecuteNonQuery(CommandBuilder.BuildSaveOrUpdateTravellerCommand(db.Connection, traveller), "outTravellerId", out travellerId); traveller.TravellerId = travellerId; return traveller; } catch (Exception ex) { errorMessage = ex.Message; DBExceptionLogger.LogException(ex, Source, "SaveOrUpdateTraveller", Severity.Critical); return null; } }