Beispiel #1
0
        async public void Register(object sender, EventArgs e)
        {
            //check  whether all data have been saved or not
            if (checkServiceArea())
            {
                //delete the current pop up
                //go to the reactions pop up
                var userAccountsProperty = Application.Current.Properties["UserAccounts"] as UserAccounts;

                //send data to API here
                HttpClientRequests        requests = new HttpClientRequests(Application.Current.Properties["Email"].ToString(), Application.Current.Properties["Password"].ToString());
                System.Net.HttpStatusCode response;
                if (_displayedData.IsItGeneral)
                {
                    string actionServiceName              = _currentService.name;
                    int    actionId                       = 0;
                    string actionAccessToken              = userAccountsProperty.UserServices[_currentService.name].accessToken;
                    string reactionServiceName            = userAccountsProperty.UserServices[_currentService.name].serviceReaction;
                    string reactionAccessToken            = userAccountsProperty.UserServices[_currentService.name].reactionAccessToken;
                    HttpClientRequests.GenericArea packet = new HttpClientRequests.GenericArea(actionServiceName, actionId, actionAccessToken, reactionServiceName, reactionAccessToken);

                    response = await requests.RegisterGenericArea(packet);
                }
                else
                {
                    string serviceName       = userAccountsProperty.UserServices[_currentService.name].serviceReaction;
                    int    areaId            = 0;
                    string actionAccessToken = userAccountsProperty.UserServices[_currentService.name].reactionAccessToken;

                    HttpClientRequests.SpecificArea packet = new HttpClientRequests.SpecificArea(serviceName, areaId, actionAccessToken);

                    response = await requests.RegisterSpecificArea(packet);
                }
                if (response == System.Net.HttpStatusCode.OK)
                {
                    await DisplayAlert("AREA", "Saved", "OK");

                    await PopupNavigation.Instance.PopAsync();
                }
                else
                {
                    await DisplayAlert("CODE", response.ToString(), "OK");
                    await DisplayAlert("FAILED", "Area not Saved", "OK");
                }
            }
            else
            {
                await DisplayAlert("Warning", "Data can't be saved, pick your area !", "OK");
            }
        }