/* * Retrieves all conversations for a user */ private async Task LoadUserConversations() { List <Conversation> rawConversations; MessagingAPI messagingApi = new MessagingAPI(); Tuple <HttpStatusCode, List <Conversation> > conversationsFetch = await messagingApi.GetConversations(localUser.id, false); switch (conversationsFetch.Item1) { case HttpStatusCode.OK: rawConversations = conversationsFetch.Item2; break; default: await DisplayAlert("", $"Failed to load conversations ({conversationsFetch.Item1})", "OK"); return; } activeConversations.Clear(); foreach (Conversation currentConversation in rawConversations) { currentConversation.getParticipantNames(localUser.id); activeConversations.Add(currentConversation.externalId); conversationList.Add(currentConversation); } }
static void Main() { //Initialize : get and return weather status/rating for dogs //Then send sms message to user WeatherRating weatherRating = new WeatherRating(); MessagingAPI messagingApi = new MessagingAPI(); //Main execution messagingApi.SendMessage(weatherRating.WeatherRatingPrint()); //weatherRating.WeatherRatingPrint(); }
/* * Retrieves a conversation */ async Task <Conversation> GetNewlyCreatedConversation(int conversationId) { MessagingAPI messagingApi = new MessagingAPI(); int localClincianId = ClinicianController.Instance.LoggedInClinician.staffID; Tuple <HttpStatusCode, Conversation> returnStatus = await messagingApi.GetConversation(localClincianId, conversationId, true); switch (returnStatus.Item1) { case HttpStatusCode.OK: // JUMP INTO CONVO return(returnStatus.Item2); default: await DisplayAlert("", "Failed to get newly created conversation (" + returnStatus.Item1 + ")", "OK"); return(null); } }
/* * Creates a new conversation between the logged in user and the * tapped user, then navigates to the page to show the new conversation */ async Task CreateConversation(int TappedUserId) { MessagingAPI messagingApi = new MessagingAPI(); int localClincianId = ClinicianController.Instance.LoggedInClinician.staffID; Tuple <HttpStatusCode, int> returnStatus = await messagingApi.CreateConversation(localClincianId, new List <int> { localClincianId, TappedUserId }); switch (returnStatus.Item1) { case HttpStatusCode.BadRequest: await DisplayAlert("", "Bad Request", "OK"); return; case HttpStatusCode.InternalServerError: await DisplayAlert("", "Server error, please try again", "OK"); return; case HttpStatusCode.Created: // JUMP INTO CONVO Conversation newlyCreatedConversation = await GetNewlyCreatedConversation(returnStatus.Item2); Clinician loggedInClinician = ClinicianController.Instance.LoggedInClinician; if (newlyCreatedConversation != null) { newlyCreatedConversation.getParticipantNames(loggedInClinician.staffID); activeConversations.Add(newlyCreatedConversation.externalId); await Navigation.PushAsync(new ConversationPage(newlyCreatedConversation, localClincianId)); } return; } }