Exemplo n.º 1
0
        public async Task <userContacts> GetUserContactsAsync(string email)
        {
            string completeUri = "http://childappapiservice.azurewebsites.net/api/contacts?email=" + email;
            Uri    requestUri  = new Uri(completeUri);

            Windows.Web.Http.HttpClient httpClient = new Windows.Web.Http.HttpClient();

            Windows.Web.Http.HttpResponseMessage httpResponse = new Windows.Web.Http.HttpResponseMessage();
            string httpResponseBody = "";

            try
            {
                //Send the GET request
                httpResponse = await httpClient.GetAsync(requestUri);

                httpResponse.EnsureSuccessStatusCode();
                httpResponseBody = await httpResponse.Content.ReadAsStringAsync();

                userContacts userContacts = JsonConvert.DeserializeObject <userContacts>(httpResponseBody);
                return(userContacts);
            }

            catch (Exception ex)
            {
            }

            return(null);
        }
Exemplo n.º 2
0
        public static async Task <bool> CheckForSimilarFriendAsync()
        {
            ConnectDB db = new ConnectDB();

            if (!(who_am_i.Equals("") || myFriend.Equals("")))
            {
                userContacts contacts = await db.GetUserContactsAsync(myFriend);

                if (contacts != null && contacts.friend != null)
                {
                    if (contacts.friend.ToLower().Equals(who_am_i.ToLower()))
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
Exemplo n.º 3
0
        public static async Task GetUserContactsAsync()
        {
            string    email = who_am_i.ToLower();
            ConnectDB db    = new ConnectDB();

            if (!who_am_i.Equals(""))
            {
                userContacts contacts = await db.GetUserContactsAsync(email);

                if (contacts != null)
                {
                    myFather  = contacts.father.ToLower();
                    myMother  = contacts.mother.ToLower();
                    myFriend  = contacts.friend.ToLower();
                    myTeacher = await db.GetGardenTeacher(who_am_i, "Teacher");
                }
                else
                {
                    Frame toAddUsersForChat = Window.Current.Content as Frame;
                    toAddUsersForChat.Navigate(typeof(AddUsersForChat));
                }
            }
        }