コード例 #1
0
        async void Login_Clicked(object sender, System.EventArgs e)
        {
            if (Email_Entry.Text == null || Email_Entry.Text == "")
            {             //if entry box was not touched (null) or is touched but empty ("")
                await DisplayAlert("Error: Email", "Please enter an email", "OK");

                return;
            }
            if (Password_Entry.Text == null || Password_Entry.Text == "")
            { //if entry box was not touched (null) or is touched but empty ("")
                await DisplayAlert("Error: Password", "Please enter a password", "OK");

                return;
            }

            //create the item we want to send
            var item = new ValidateUserItem();

            item.Email    = Email_Entry.Text;
            item.Password = Password_Entry.Text;

            sts.send(uri, item, async() =>
            {
                App.userEmail    = item.Email;
                App.userPassword = item.Password;

                await Navigation.PushAsync(new HomePage()); //goto home page
            });
        }
コード例 #2
0
ファイル: HomePage.xaml.cs プロジェクト: munoz059/Classy-App
        public void GetMyClassrooms()
        {
            //create the item we want to send
            var item = new GetUserClassroomsItem();

            item.Email    = App.userEmail;
            item.Password = App.userPassword;

            sts.send(uri, item, async() =>
            {
                try
                {
                    if (sts.responseItem.Data != "")
                    {
                        var classroomList = JsonConvert.DeserializeObject <List <ClassroomInfoItem> >(sts.responseItem.Data);
                        for (int i = 0; i < classroomList.Count; i++)
                        {
                            _ClassroomListViewItems.Add(classroomList[i]);
                        }
                    }
                }
                catch (Exception ex)
                {
                    await DisplayAlert("Unexpected Parsing Error", ex.Message, "OK");
                }
            });
        }
コード例 #3
0
ファイル: testPage1.xaml.cs プロジェクト: munoz059/Classy-App
        public void getForumItems()
        {
            //create the item we want to send
            var item = new GetForumThreadsItem();

            item.Email      = App.userEmail;
            item.Password   = App.userPassword;
            item.DatabaseId = App.curClassroom.Id;

            sts.send(uri, item, async() =>
            {
                try
                {
                    if (sts.responseItem.Data != "")
                    {
                        var forumItemList = JsonConvert.DeserializeObject <List <ForumThreadItem> >(sts.responseItem.Data);
                        for (int i = 0; i < forumItemList.Count; i++)
                        {
                            if (!_ForumListViewItems.Contains(forumItemList[i]))
                            {
                                _ForumListViewItems.Add(forumItemList[i]);
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    await DisplayAlert("Unexpected Parsing Error", ex.Message, "OK");
                }
            });
        }
コード例 #4
0
        void ChatroomItemCell_OnLeave(object sender, EventArgs e)
        {
            Debug.WriteLine(((MenuItem)sender).BindingContext.ToString());
            var item = new LeaveChatroomItem();

            item.ChatroomId = ((ChatroomItem)((MenuItem)sender).BindingContext).Id;
            item.Email      = App.userEmail;
            item.Password   = App.userPassword;
            item.DatabaseId = App.curClassroom.Id;

            sts.send(uri, item, () =>
            {
                Handle_Refreshing(null, null);
            });
        }
コード例 #5
0
        // this method currently in testing
        public async void CreateAccount(object sender, EventArgs e)
        {
            if (Name_Entry.Text == null || Name_Entry.Text == "")
            { //if entry box was not touched (null) or is touched but empty ("")
                await DisplayAlert("Error: Name", "Please enter a name", "OK");

                return;
            }
            if (Email_Entry.Text == null || Email_Entry.Text == "")
            { //if entry box was not touched (null) or is touched but empty ("")
                await DisplayAlert("Error: Email", "Please enter an email", "OK");

                return;
            }
            if (Password_Entry.Text == null || Password_Entry.Text == "" || Password_Entry.Text != ReEnterPassword_Entry.Text)
            {             //if the entry box was not touched (null), is touched but empty (""), or both password entries do not match
                await DisplayAlert("Error: Password", "Please make sure both password fields match and are not empty", "OK");

                return;
            }

            //create item we want to send
            var item = new AddUserItem();

            item.Name     = Name_Entry.Text;
            item.Email    = Email_Entry.Text;
            item.Password = Password_Entry.Text;

            sts.send(uri, item, async() =>
            {
                await DisplayAlert("Success", "Account successfully created", "OK");
                await Navigation.PopAsync();
            });
        }
コード例 #6
0
        public void GetForumPostItems()
        {
            var item = new GetForumPostsItem();

            item.ThreadId   = _forumThread.Id;
            item.Email      = App.userEmail;
            item.Password   = App.userPassword;
            item.DatabaseId = App.curClassroom.Id;

            sts.send(uri, item, async() =>
            {
                try
                {
                    if (sts.responseItem.Data != "")
                    {
                        var ForumPostsItemList = JsonConvert.DeserializeObject <List <ForumPostItem> >(sts.responseItem.Data);

                        for (int i = 0; i < ForumPostsItemList.Count; i++)
                        {
                            if (i == 0)
                            {
                                ForumPostsItemList[i].isFirstPost = true;
                            }
                            _ForumPostsListViewItems.Add(ForumPostsItemList[i]);
                        }
                        ForumPostsListView.ScrollTo(ForumPostsItemList[_ForumPostsListViewItems.Count - 1], ScrollToPosition.MakeVisible, true);
                    }
                }
                catch (Exception ex)
                {
                    await DisplayAlert("Unexpected Parsing Error", ex.Message, "OK");
                }
            });
        }
コード例 #7
0
        public void SendButton_OnClicked(object sender, EventArgs e)
        {
            if (Message_Editor.Text == null || Message_Editor.Text == "")
            {
                return;
            }

            var item = new PostChatroomMessageItem();

            item.ChatroomId = chatroom.Id;
            item.Email      = App.userEmail;
            item.Password   = App.userPassword;
            item.DatabaseId = App.curClassroom.Id;
            item.Message    = Message_Editor.Text;

            sts.send(uri, item, () =>
            {
                Message_Editor.Text = "";
                Handle_Refreshing(null, null);
            });
        }
コード例 #8
0
        public async void Button_OnCreate(object sender, EventArgs e)
        {
            if (App.userEmail == null || App.userPassword == null)
            {
                //internal error, these should not be null at this point
                await DisplayAlert("Error: Internal Error", "An unexpected error has occurred. Try logging out and back in.", "OK");

                return;
            }

            var item = new CreateChatroomItem();

            item.MemberIds  = MemberIds;
            item.Email      = App.userEmail;
            item.Password   = App.userPassword;
            item.DatabaseId = App.curClassroom.Id;

            sts.send(uri, item, async() =>
            {
                await DisplayAlert("Success", "Chatroom successfully created", "OK");
                await Navigation.PopAsync();
            });
        }
コード例 #9
0
        public async void UserItemCell_OnDrop(object sender, EventArgs e)
        {
            bool answer = await DisplayAlert("Drop User", "Are you sure you want to drop this user from the classroom?", "Yes", "No");

            if (answer == false)
            {
                return;
            }

            var selectedUser = (UserItem)((MenuItem)sender).BindingContext;

            var item = new DropUserItem();

            item.DatabaseId = App.curClassroom.Id;
            item.Email      = App.userEmail;
            item.Password   = App.userPassword;
            item.DropId     = selectedUser.Id;

            sts.send(uri, item, async() =>
            {
                await DisplayAlert("Success", "User successfully dropped from the classroom", "OK");
                Handle_Refreshing(null, null);
            });
        }
コード例 #10
0
        public async void Button_OnSave(object sender, EventArgs e)
        {
            if (App.userEmail == null || App.userPassword == null)
            {
                //internal error, these should not be null at this point
                await DisplayAlert("Error: Internal Error", "An unexpected error has occurred. Try logging out and back in.", "OK");

                return;
            }

            if (Title_Entry.Text == null || Title_Entry.Text == "")
            {
                await DisplayAlert("Error: Title", "Please enter a title", "OK");

                return;
            }

            object item;

            if (isNew)
            {
                var temp_item = new CreateClassroomItem();
                temp_item.Title       = Title_Entry.Text;
                temp_item.Description = Description_Editor.Text;
                temp_item.Email       = App.userEmail;
                temp_item.Password    = App.userPassword;

                item = temp_item;
            }
            else
            {
                var temp_item = new EditClassroomItem();
                temp_item.Title       = Title_Entry.Text;
                temp_item.Description = Description_Editor.Text;
                temp_item.Email       = App.userEmail;
                temp_item.Password    = App.userPassword;
                temp_item.DatabaseId  = classroom.Id;

                item = temp_item;
            }

            sts.send(uri, item, () =>
            {
                Navigation.PopAsync();
            });
        }
コード例 #11
0
        async void InviteButton_OnClicked(object sender, EventArgs e)
        {
            if (Email_Entry.Text == null || Email_Entry.Text == "")
            {
                await DisplayAlert("Error", "Please enter an email", "OK");

                return;
            }

            var item = new InviteUserItem();

            item.DatabaseId  = App.curClassroom.Id;
            item.Email       = App.userEmail;
            item.Password    = App.userPassword;
            item.InviteEmail = Email_Entry.Text;

            sts.send(uri, item, async() => {
                await DisplayAlert("Success", "Invite successfully sent", "OK");
                //await Navigation.PopAsync();
            });
        }
コード例 #12
0
ファイル: testPage2.xaml.cs プロジェクト: munoz059/Classy-App
        public void getTodoItems()
        {
            //create the item we want to send
            var item = new GetTodoItems();

            item.Email      = App.userEmail;
            item.Password   = App.userPassword;
            item.DatabaseId = App.curClassroom.Id;

            sts.send(uri, item, async() =>
            {
                try
                {
                    if (sts.responseItem.Data != "")
                    {
                        var todoItemList = JsonConvert.DeserializeObject <List <TodoItem> >(sts.responseItem.Data);
                        for (int i = 0; i < todoItemList.Count; i++)
                        {
                            if (todoItemList[i].DueDateTime == DateTime.MinValue)
                            {
                                todoItemList[i].HasDueDate = false;
                            }
                            else
                            {
                                todoItemList[i].HasDueDate = true;
                            }

                            _TodoListViewItems.Add(todoItemList[i]);
                        }
                    }
                }
                catch (Exception ex)
                {
                    await DisplayAlert("Unexpected Parsing Error", ex.Message, "OK");
                }
            });
        }
コード例 #13
0
        async void JoinButton_OnClicked(object sender, EventArgs e)
        {
            if (ClassroomId_Entry.Text == null || ClassroomId_Entry.Text == "")
            {
                await DisplayAlert("Error", "Please enter a classroom ID", "OK");

                return;
            }

            if (ClassroomId_Entry.Text.Length != 10)
            {
                await DisplayAlert("Error", "A classroom ID must contain exactly 10 digits", "OK");

                return;
            }

            foreach (char ch in ClassroomId_Entry.Text)
            {
                if (ch < '0' || ch > '9')
                {
                    await DisplayAlert("Error", "A classroom ID can only contain numbers", "OK");

                    return;
                }
            }

            var item = new JoinClassroomItem();

            item.DatabaseId = ClassroomId_Entry.Text;
            item.Email      = App.userEmail;
            item.Password   = App.userPassword;

            sts.send(uri, item, async() => {
                await DisplayAlert("Success", "Classroom successfully joined", "OK");
                await Navigation.PopAsync();
            });
        }
コード例 #14
0
        public async void Button_OnSave(object sender, EventArgs e)
        {
            if (App.curClassroom.Id == null || App.userEmail == null || App.userPassword == null)
            {
                //internal error, these should not be null at this point
                await DisplayAlert("Error: Internal Error", "An unexpected error has occurred. Try logging out and back in.", "OK");

                return;
            }

            if (Title_Entry.Text == null || Title_Entry.Text == "")
            {
                await DisplayAlert("Error: Title", "Please enter a title", "OK");

                return;
            }

            object item;

            if (isNew)
            {
                var temp_item = new CreateTodoItem();
                temp_item.Title       = Title_Entry.Text;
                temp_item.Description = Description_Editor.Text;
                if (HasDueDateSwitch.IsToggled)
                {
                    temp_item.DueDateTime = DueDate_DatePicker.Date.Add(DueDate_TimePicker.Time);
                }
                else
                {
                    temp_item.DueDateTime = DateTime.MinValue; //1/1/0001 12:00:00AM
                }
                temp_item.DatabaseId = App.curClassroom.Id;
                temp_item.Email      = App.userEmail;
                temp_item.Password   = App.userPassword;

                if (temp_item.DueDateTime < DateTime.Now && HasDueDateSwitch.IsToggled)
                {
                    await DisplayAlert("Error: Due Date", "The due date cannot be in the past", "OK");

                    return;
                }
                item = temp_item;
            }
            else
            {
                var temp_item = new EditTodoItem();
                temp_item.Title       = Title_Entry.Text;
                temp_item.Description = Description_Editor.Text;
                if (HasDueDateSwitch.IsToggled)
                {
                    temp_item.DueDateTime = DueDate_DatePicker.Date.Add(DueDate_TimePicker.Time);
                }
                else
                {
                    temp_item.DueDateTime = DateTime.MinValue; //1/1/0001 12:00:00AM
                }
                temp_item.DatabaseId = App.curClassroom.Id;
                temp_item.Email      = App.userEmail;
                temp_item.Password   = App.userPassword;
                temp_item.TodoItemId = _model.Id;

                if (temp_item.DueDateTime < DateTime.Now && HasDueDateSwitch.IsToggled)
                {
                    await DisplayAlert("Error: Due Date", "The due date cannot be in the past", "OK");

                    return;
                }
                item = temp_item;
            }

            sts.send(uri, item, () =>
            {
                Navigation.PopAsync();
            });
        }