/// <summary> /// Saves the company info to the database /// </summary> /// <param name="compo">Information about the company</param> public void saveCompany(CompanyListingsEvent compo) { if (openConnection()) { try { string query = @"INSERT INTO " + databaseName + @".Companies " + @"VALUES('" + compo.company.companyName + @"', '" + compo.company.email + @"', '" + compo.company.phoneNumber + @"', '" + compo.company.locations[0] + @"');"; //Assumes array of length one (only oone location) MySqlCommand command = new MySqlCommand(query, connection); command.ExecuteNonQuery(); } catch (Exception a) { Console.WriteLine("Issue saving company to the database."); Console.WriteLine(a.Message); } finally { closeConnection(); } } else { Debug.consoleMsg("Unable to connect to database"); } }
/// <summary> /// Parses new account info and attempts to insert the new account into the authentication database /// It also publishes an "AccountCreated" event /// </summary> /// <returns>A response message</returns> private ServiceBusResponse attemptNewAccountCreation(CreateAccountRequest request) { CreateAccount command = request.createCommand; ServiceBusResponse dbResponse = AuthenticationDatabase.getInstance().insertNewUserAccount(command); if (dbResponse.result == true) { authenticated = true; username = command.username; password = command.password; initializeRequestingEndpoint(); eventPublishingEndpoint.Publish(new AccountCreated(command)); // Publish company event for company to be saved in DB if (request.createCommand.type == Messages.DataTypes.AccountType.business) { string[] loc = new string[1]; loc[0] = request.createCommand.address; CompanyListingsEvent comp = new CompanyListingsEvent(new CompanyInstance(request.createCommand.username, request.createCommand.phonenumber, request.createCommand.email, loc)); eventPublishingEndpoint.Publish(comp); } } return(dbResponse); }