Beispiel #1
0
        private async System.Threading.Tasks.Task ChangeAccessLevel(UserListAccess access)
        {
            AreBtnsEn = false;

            string inputNewAccessLevel = await Application.Current.MainPage.DisplayPromptAsync("New Access", "Insert his/her access level: \n 1 - Viewer \n 2 - Editor \n 3 - Admin");

            if (String.IsNullOrEmpty(inputNewAccessLevel))
            {
                return;
            }

            int newAccessLevel = Convert.ToInt32(inputNewAccessLevel);

            if (newAccessLevel > 0 && newAccessLevel < 4)
            {
                var checkResult = await n_Restctrl.ChangeUserAccess(newAccessLevel, access.AccessID);

                if (checkResult.StatusCode == HttpStatusCode.OK)
                {
                    await Refresh();
                }
                else if (checkResult.StatusCode == System.Net.HttpStatusCode.Unauthorized)
                {
                    await Application.Current.MainPage.DisplayAlert("Sorry", "You do not have permission to do this", "Ok");
                }
                else
                {
                    await Application.Current.MainPage.DisplayAlert("Sorry", "Something went wrong, check your connection", "Ok");
                }
            }
            else
            {
                await Application.Current.MainPage.DisplayAlert("Sorry", "Wrong input format", "Ok");
            }
            AreBtnsEn = true;
        }