async Task SendCommentToServer(string comment)
        {
            var datasource = DjangoAPI.Instance();
            var result     = await datasource.CreateAComment(new CommentRequest
            {
                post    = post.id,
                comment = comment
            });

            Device.BeginInvokeOnMainThread(() =>
            {
                if (result == 0)
                {
                    commentList.Add(new Comment
                    {
                        author  = Constants.user.name + " " + Constants.user.last,
                        comment = comment
                    });
                }
                else
                {
                    DisplayAlert("Information", "An error occurs", "Ok");
                }
            });
        }
Beispiel #2
0
        async Task AuthenticateAttempt(AuthRequest request)
        {
            var datasource = DjangoAPI.Instance();
            var result     = await datasource.Authenticate(request);

            Device.BeginInvokeOnMainThread(() =>
            {
                IsLoading = false;
                if (result != null && result.code == 0)
                {
                    Application.Current.MainPage = new NavigationPage(new HomePage());
                }
                else
                {
                    DisplayAlert("Information", "An Error occurs, please try again", "Ok");
                }
            });
        }
Beispiel #3
0
        async Task FetchPosts()
        {
            var datasource = DjangoAPI.Instance();
            var res        = await datasource.FetchPosts();

            Device.BeginInvokeOnMainThread(() =>
            {
                if (res != null && res.Count > 0)
                {
                    postList             = new ObservableCollection <Post>(res);
                    PostList.ItemsSource = postList;
                }
                else
                {
                    DisplayAlert("Information", "Data could not be obtained, try again", "Ok");
                }
            });
        }
Beispiel #4
0
        async Task SignupRequest(SignupRequest request)
        {
            var datasource = DjangoAPI.Instance();
            var result     = await datasource.SignupRequest(request);

            Device.BeginInvokeOnMainThread(() =>
            {
                IsLoading = false;
                if (result != null && result.code == 0)
                {
                    DisplayAlert("Information", "Signup proccess completed. Please login with your credentials", "Ok");
                    Navigation.PopAsync();
                }
                else
                {
                    DisplayAlert("Information", "An Error occurs, please try again", "Ok");
                }
            });
        }