/// <summary> /// Creates the API request to add a new client to the database, and handles the response /// </summary> /// <param name="client">Client as a JSON string to be added to the system</param> private void AddClientToDatabase(string client) { APIRequests request = new APIRequests(); string url = $"{request.allClientDetailsEndpoint}"; string response = request.SendPOSTRequestDataInBody(url, client); //logger.Info(response); if (response.Contains("Successfully added new client")) { bool successfullyAdded = AddClientToClientDb(response); if (successfullyAdded) { MessageBox.Show("Successfully added client to the system"); } else { MessageBox.Show("Client succesfully added to main database, but failed to add it to the client login database"); } } else { MessageBox.Show("Something went wrong"); } }
private string AddTrainingSessionTodatabase(string session) { APIRequests request = new APIRequests(); string url = request.allTrainingSessionsEndpoint; string response = request.SendPOSTRequestDataInBody(url, session); return(response); }
/// <summary> /// Method for creating the request and sending it off to the server to add a new exercise /// </summary> /// <param name="exercise">Exercise object as a JSON string</param> private static void AddExerciseToDatabase(string exercise) { APIRequests request = new APIRequests(); string url = $"{request.allExercisesEndpoint}"; string response = request.SendPOSTRequestDataInBody(url, exercise); logger.Info(response); if (response.Contains("Successfully added new exercise")) { MessageBox.Show("Successfully added exercise to the system"); } else { MessageBox.Show("Something went wrong"); } }