public async Task BlockStudent(PublicUserData StudentPublicData)
 {
     IList<ParseUser> blocked = this.Blocked;
     blocked.Add(ParseUser.CreateWithoutData<ParseUser>(StudentPublicData.BaseUserId));
     this.Blocked = blocked;
     await this.SaveAsync();
 }
        protected async Task AssignQuestionToStudent(string questionObjectId, string studentObjectId)
        {
            var            query = new ParseQuery <PublicUserData>();
            PublicUserData pud   = await query.GetAsync(studentObjectId);

            //Student student = await pud.Student.FetchIfNeededAsync();
            //PrivateStudentData psd = await student.PrivateStudentData.FetchIfNeededAsync();

            Question          question          = Question.CreateWithoutData <Question>(questionObjectId);
            SuggestedQuestion suggestedQuestion = new SuggestedQuestion();

            suggestedQuestion.Answered          = false;
            suggestedQuestion.Question          = question;
            suggestedQuestion.Response          = null;
            suggestedQuestion.StudentBaseUserId = pud.BaseUserId;
            suggestedQuestion.Tutor             = PublicUserData;
            await suggestedQuestion.SaveAsync();

            //psd.AssignedQuestions.Add(suggestedQuestion);
            //await psd.SaveAsync();

            IDictionary <string, object> parameters = new Dictionary <string, object>
            {
                { "baseUserId", pud.BaseUserId },
                { "suggestedQuestionId", suggestedQuestion.ObjectId }
            };
            await ParseCloud.CallFunctionAsync <string>("assignQuestion", parameters);
        }
Exemple #3
0
 protected void grdTutors_RowCommand(object sender, GridViewCommandEventArgs e)
 {
     if (e.CommandName == "Message")
     {
         int    index         = Convert.ToInt32(e.CommandArgument);
         string TheirObjectId = (string)grdTutors.DataKeys[index]["ObjectId"];
         Session["ConversationUserId"] = TheirObjectId;
         Response.Redirect("Messages");
     }
     else if (e.CommandName == "SeeProfile")
     {
         int    index         = Convert.ToInt32(e.CommandArgument);
         string TheirObjectId = (string)grdTutors.DataKeys[index]["ObjectId"];
         Response.Redirect("Profile.aspx?tutorId=" + TheirObjectId);
     }
     else if (e.CommandName == "ToggleModerator")
     {
         string         TheirObjectId = e.CommandArgument.ToString();
         PublicUserData pud           = AsyncHelpers.RunSync(() => PublicUserData.GetById(TheirObjectId));
         if (pud.UserType == Constants.UserType.TUTOR)
         {
             pud.UserType = Constants.UserType.MODERATOR;
         }
         else if (pud.UserType == Constants.UserType.MODERATOR)
         {
             pud.UserType = Constants.UserType.TUTOR;
         }
         AsyncHelpers.RunSync(() => pud.SaveAsync());
     }
     AsyncHelpers.RunSync(LoadEverything);
 }
        protected override async Task OnStart()
        {
            if (!this.IsPostBack)
            {
                string studentID = Request.QueryString["StudentId"];
                StudentPublicData = await PublicUserData.GetById(studentID);

                Image1.ImageUrl = StudentPublicData.ProfilePic != null?StudentPublicData.ProfilePic.Url.ToString() : "Images/default_prof_pic.png";

                await PrivateTutorData.Students.FetchAllIfNeededAsync();
            }
            FixButtonVisibility();

            if (Common.ParseContains(PrivateTutorData.Students, StudentPublicData))
            {
                pnlAssignedQuestions.Visible    = true;
                pnlAnalyticsHolder.Visible      = true;
                grdAssignedQuestions.DataSource = await SuggestedQuestion.GetAssignedQuestionsBetweenStudentTutor(StudentPublicData, PublicUserData);

                grdAssignedQuestions.DataBind();
            }
            else
            {
                pnlAssignedQuestions.Visible = false;
                pnlAnalyticsHolder.Visible   = false;
            }
        }
        public async Task BlockStudent(PublicUserData StudentPublicData)
        {
            IList <ParseUser> blocked = this.Blocked;

            blocked.Add(ParseUser.CreateWithoutData <ParseUser>(StudentPublicData.BaseUserId));
            this.Blocked = blocked;
            await this.SaveAsync();
        }
 public static async Task<IList<SuggestedQuestion>> GetAssignedQuestionsBetweenStudentTutor(PublicUserData studentPublicData, PublicUserData tutorPublicData)
 {
     IDictionary<string, object> parameters = new Dictionary<string, object>
     {
         { "studentPublicDataId", studentPublicData.ObjectId },
         { "tutorPublicDataId", tutorPublicData.ObjectId }
     };
     IList<SuggestedQuestion> assignedQuestions = await ParseCloud.CallFunctionAsync<IList<SuggestedQuestion>>("assignedQuestionsToStudent", parameters);
     return assignedQuestions;
 }
 public async Task SendRequestToStudent(PublicUserData StudentPublicData, PublicUserData TutorPublicData)
 {
     //Student student = await StudentPublicData.Student.FetchIfNeededAsync();
     //PrivateStudentData privateStudentData = student.PrivateStudentData;
     IDictionary<string, object> parameters = new Dictionary<string, object>
     {
         { "publicStudentDataId", StudentPublicData.ObjectId },
         { "publicTutorDataId", TutorPublicData.ObjectId }
     };
     await ParseCloud.CallFunctionAsync<string>("tutorRequestToStudent", parameters);
 }
 public async Task SendRequestToStudent(PublicUserData StudentPublicData, PublicUserData TutorPublicData)
 {
     //Student student = await StudentPublicData.Student.FetchIfNeededAsync();
     //PrivateStudentData privateStudentData = student.PrivateStudentData;
     IDictionary <string, object> parameters = new Dictionary <string, object>
     {
         { "publicStudentDataId", StudentPublicData.ObjectId },
         { "publicTutorDataId", TutorPublicData.ObjectId }
     };
     await ParseCloud.CallFunctionAsync <string>("tutorRequestToStudent", parameters);
 }
        public async Task RemoveStudent(PublicUserData StudentPublicData, PublicUserData TutorPublicData)
        {
            Students = Common.RemoveFromList(Students, StudentPublicData);
            await this.SaveAsync();

            Student student = await StudentPublicData.Student.FetchIfNeededAsync();

            PrivateStudentData           privateStudentData = student.PrivateStudentData;
            IDictionary <string, object> parameters         = new Dictionary <string, object>
            {
                { "privateStudentDataId", privateStudentData.ObjectId },
                { "tutorPublicDataId", TutorPublicData.ObjectId }
            };
            await ParseCloud.CallFunctionAsync <string>("removeTutor", parameters);
        }
        protected override async Task OnStart()
        {
            string tutorId = Request.QueryString["tutorId"];

            theirPublicUserData = await PublicUserData.GetPublicTutorDataById(tutorId);

            theirTutor      = theirPublicUserData.Tutor;
            Image1.ImageUrl = theirPublicUserData.ProfilePic != null?theirPublicUserData.ProfilePic.Url.ToString() : "Images/default_prof_pic.png";

            edit.Visible           = IsMyProfile;
            EditAboutMeBtn.Visible = IsMyProfile;
            btnSendMessage.Visible = !IsMyProfile;
            //theirPublicUserData.ProfilePic = null;
            //await theirPublicUserData.SaveAsync();
        }
 public async Task FillResults()
 {
     if (String.IsNullOrEmpty(TextBox1.Text))
     {
         Repeater1.DataSource = null;
         Repeater1.DataBind();
     }
     else
     {
         System.Diagnostics.Debug.WriteLine("hello again");
         IEnumerable <PublicUserData> data = (await PublicUserData.Search(TextBox1.Text)).Take(5);
         //await data.FetchAllIfNeededAsync();
         System.Diagnostics.Debug.WriteLine("hello agaiagainn");
         Repeater1.DataSource = data;
         Repeater1.DataBind();
     }
 }
Exemple #12
0
        protected async Task <ParseObject> FindOrCreateNewConversation()
        {
            ParseObject conversation = await GetThisConversation(RecipientPublicData.Get <string>("baseUserId"));

            if (conversation != null)
            {
                return(conversation);
            }
            else
            {
                conversation = new ParseObject("Conversation");
                conversation["publicUserData1"] = PublicUserData;
                conversation["publicUserData2"] = RecipientPublicData;
                conversation["baseUserId1"]     = PublicUserData.Get <string>("baseUserId");
                conversation["baseUserId2"]     = RecipientPublicData.Get <string>("baseUserId");
                await conversation.SaveAsync();

                return(conversation);
            }
        }
        public async Task AcceptStudentRequest(PublicUserData StudentPublicData, PublicUserData TutorPublicData)
        {
            RequestsFromStudents = Common.RemoveFromList(RequestsFromStudents, StudentPublicData);

            IList<PublicUserData> students = Students;
            students.Add(StudentPublicData);
            Students = students;

            Student student = await StudentPublicData.Student.FetchIfNeededAsync();
            PrivateStudentData privateStudentData = student.PrivateStudentData;
            IDictionary<string, object> parameters = new Dictionary<string, object>
            {
                { "privateStudentDataId", privateStudentData.ObjectId },
                { "tutorPublicDataId", TutorPublicData.ObjectId }
            };
            await ParseCloud.CallFunctionAsync<string>("addTutor", parameters);

            //this.AddUniqueToList("students", StudentPublicData);
            await this.SaveAsync();
        }
Exemple #14
0
        protected async Task StartPage()
        {
            if (NewSession)
            {
                RegisterParseSubclasses();
                ParseClient.Initialize("iT8NyJO0dChjLyfVsHUTM8UZQLSBBJLxd43AX9IY", "SvmmmluPjmLblmNrgqnUmylInkyiXzoWBk9ZxeZH");
                NewSession = false;
            }
            if (IsTestMode)
            {
                Session["Email"]    = "*****@*****.**";
                Session["Password"] = "******";
            }
            if (LoggedIn)
            {
                //if (ParseUser.CurrentUser == null)
                //{
                await ParseUser.LogInAsync(Session["Email"].ToString(), Session["Password"].ToString());

                //}
                //PublicUserData = ParseUser.CurrentUser.Get<PublicUserData>("publicUserData");
                //await PublicUserData.FetchAsync();
                //Tutor = PublicUserData.Tutor;
                //await Tutor.FetchAsync();
                //PrivateTutorData = Tutor.PrivateTutorData;
                //await PrivateTutorData.FetchAsync();

                //ParseObject[] data = new ParseObject[] {PublicUserData, Tutor, PrivateTutorData};
                //await data.FetchAllAsync();
                PublicUserData = await PublicUserData.GetTutorDataById(PublicUserData.ObjectId);
            }
            else
            {
                if (!(this is _Default || this is Register || this is RegistrationTest || this is RegisterSuccess || this is RegisterFailure || this is Login))
                {
                    Response.Redirect("Default");
                }
            }
            await OnStart();
        }
        public async Task AcceptStudentRequest(PublicUserData StudentPublicData, PublicUserData TutorPublicData)
        {
            RequestsFromStudents = Common.RemoveFromList(RequestsFromStudents, StudentPublicData);

            IList <PublicUserData> students = Students;

            students.Add(StudentPublicData);
            Students = students;

            Student student = await StudentPublicData.Student.FetchIfNeededAsync();

            PrivateStudentData           privateStudentData = student.PrivateStudentData;
            IDictionary <string, object> parameters         = new Dictionary <string, object>
            {
                { "privateStudentDataId", privateStudentData.ObjectId },
                { "tutorPublicDataId", TutorPublicData.ObjectId }
            };
            await ParseCloud.CallFunctionAsync <string>("addTutor", parameters);

            //this.AddUniqueToList("students", StudentPublicData);
            await this.SaveAsync();
        }
        protected override async Task OnStart()
        {
            if (!this.IsPostBack)
            {
                string studentID = Request.QueryString["StudentId"];
                StudentPublicData = await PublicUserData.GetById(studentID);
                Image1.ImageUrl = StudentPublicData.ProfilePic != null ? StudentPublicData.ProfilePic.Url.ToString() : "Images/default_prof_pic.png";
                await PrivateTutorData.Students.FetchAllIfNeededAsync();
            }
            FixButtonVisibility();

            if (Common.ParseContains(PrivateTutorData.Students, StudentPublicData))
            {
                pnlAssignedQuestions.Visible = true;
                pnlAnalyticsHolder.Visible = true;
                grdAssignedQuestions.DataSource = await SuggestedQuestion.GetAssignedQuestionsBetweenStudentTutor(StudentPublicData, PublicUserData);
                grdAssignedQuestions.DataBind();
            }
            else
            {
                pnlAssignedQuestions.Visible = false;
                pnlAnalyticsHolder.Visible = false;
            }
        }
        public async Task RemoveStudent(PublicUserData StudentPublicData, PublicUserData TutorPublicData)
        {
            Students = Common.RemoveFromList(Students, StudentPublicData);
            await this.SaveAsync();

            Student student = await StudentPublicData.Student.FetchIfNeededAsync();
            PrivateStudentData privateStudentData = student.PrivateStudentData;
            IDictionary<string, object> parameters = new Dictionary<string, object>
            {
                { "privateStudentDataId", privateStudentData.ObjectId },
                { "tutorPublicDataId", TutorPublicData.ObjectId }
            };
            await ParseCloud.CallFunctionAsync<string>("removeTutor", parameters);
        }
Exemple #18
0
        protected async Task LoadEverything()
        {
            grdTutors.DataSource = await PublicUserData.AllTutors();

            grdTutors.DataBind();
        }
        private async Task SignUp(int registrationTestScore)
        {
            ParseRole adminRole = await Constants.Role.Admin();
            var user = new ParseUser()
            {
                Username = MyRegistrationInfo.Email.ToLower(),
                Password = MyRegistrationInfo.Password,
                Email = MyRegistrationInfo.Email.ToLower(),
            };
            await user.SignUpAsync();

            ParseRole tutorRole = await Constants.Role.Tutor();
            tutorRole.Users.Add(user);
            await tutorRole.SaveAsync();

            PrivateTutorData privateTutorData = new PrivateTutorData();
            privateTutorData.BaseUserId = user.ObjectId;
            privateTutorData.Students = new List<PublicUserData>();
            privateTutorData.RequestsFromStudents = new List<PublicUserData>();
            privateTutorData.Blocked = new List<ParseUser>();
            privateTutorData.ACL = new ParseACL(user);
            privateTutorData.ACL.SetRoleReadAccess(adminRole, true);
            privateTutorData.ACL.SetRoleWriteAccess(adminRole, true);
            await privateTutorData.SaveAsync();

            Tutor tutor = new Tutor();
            tutor.NumQuestionsCreated = 0;
            tutor.NumQuestionsReviewed = 0;
            tutor.BaseUserId = user.ObjectId;
            tutor.Biography = "";
            tutor.PrivateTutorData = privateTutorData;
            tutor.ACL = new ParseACL();
            tutor.ACL.PublicReadAccess = true;
            tutor.ACL.PublicWriteAccess = false;
            tutor.ACL.SetWriteAccess(user, true);
            tutor.ACL.SetRoleReadAccess(adminRole, true);
            tutor.ACL.SetRoleWriteAccess(adminRole, true);
            await tutor.SaveAsync();

            PublicUserData publicUserData = new PublicUserData();
            publicUserData.UserType = Constants.UserType.TUTOR;
            publicUserData.DisplayName = MyRegistrationInfo.FirstName.Trim() + " " + MyRegistrationInfo.LastName.Trim();
            publicUserData.SearchableDisplayName = MyRegistrationInfo.FirstName.Trim().ToLower() + MyRegistrationInfo.LastName.Trim().ToLower();
            publicUserData.BaseUserId = user.ObjectId;
            publicUserData.Tutor = tutor;
            string path = HttpContext.Current.Server.MapPath("~/Images/default_prof_pic.png");
            byte[] pic = File.ReadAllBytes(path);
            publicUserData.ProfilePic = new ParseFile("default-profile-pic", pic);
            publicUserData.ACL = new ParseACL();
            publicUserData.ACL.PublicReadAccess = true;
            publicUserData.ACL.PublicWriteAccess = false;
            publicUserData.ACL.SetWriteAccess(user, true);
            publicUserData.ACL.SetRoleReadAccess(adminRole, true);
            publicUserData.ACL.SetRoleWriteAccess(adminRole, true);
            await publicUserData.SaveAsync();

            user["registrationTestScore"] = registrationTestScore;
            user.ACL = new ParseACL(user);
            user.ACL.SetRoleReadAccess(adminRole, true);
            user["publicUserData"] = publicUserData;
            //user.phoneNumber = tbPhoneNumber.Text;
            //user.zipCode = tbZipCode.Text;
            //user.address = tbStreetAddress.Text;
            //user.address2 = tbAddress2.Text;
            //user.city = tbCity.Text;
            //user.state = ddState.SelectedValue;
            await user.SaveAsync();
        }
Exemple #20
0
        public static async Task <IList <SuggestedQuestion> > GetAssignedQuestionsBetweenStudentTutor(PublicUserData studentPublicData, PublicUserData tutorPublicData)
        {
            IDictionary <string, object> parameters = new Dictionary <string, object>
            {
                { "studentPublicDataId", studentPublicData.ObjectId },
                { "tutorPublicDataId", tutorPublicData.ObjectId }
            };
            IList <SuggestedQuestion> assignedQuestions = await ParseCloud.CallFunctionAsync <IList <SuggestedQuestion> >("assignedQuestionsToStudent", parameters);

            return(assignedQuestions);
        }
        private async Task SignUp(int registrationTestScore)
        {
            ParseRole adminRole = await Constants.Role.Admin();

            var user = new ParseUser()
            {
                Username = MyRegistrationInfo.Email.ToLower(),
                Password = MyRegistrationInfo.Password,
                Email    = MyRegistrationInfo.Email.ToLower(),
            };
            await user.SignUpAsync();

            ParseRole tutorRole = await Constants.Role.Tutor();

            tutorRole.Users.Add(user);
            await tutorRole.SaveAsync();

            PrivateTutorData privateTutorData = new PrivateTutorData();

            privateTutorData.BaseUserId           = user.ObjectId;
            privateTutorData.Students             = new List <PublicUserData>();
            privateTutorData.RequestsFromStudents = new List <PublicUserData>();
            privateTutorData.Blocked = new List <ParseUser>();
            privateTutorData.ACL     = new ParseACL(user);
            privateTutorData.ACL.SetRoleReadAccess(adminRole, true);
            privateTutorData.ACL.SetRoleWriteAccess(adminRole, true);
            await privateTutorData.SaveAsync();

            Tutor tutor = new Tutor();

            tutor.NumQuestionsCreated  = 0;
            tutor.NumQuestionsReviewed = 0;
            tutor.BaseUserId           = user.ObjectId;
            tutor.Biography            = "";
            tutor.PrivateTutorData     = privateTutorData;
            tutor.ACL = new ParseACL();
            tutor.ACL.PublicReadAccess  = true;
            tutor.ACL.PublicWriteAccess = false;
            tutor.ACL.SetWriteAccess(user, true);
            tutor.ACL.SetRoleReadAccess(adminRole, true);
            tutor.ACL.SetRoleWriteAccess(adminRole, true);
            await tutor.SaveAsync();

            PublicUserData publicUserData = new PublicUserData();

            publicUserData.UserType              = Constants.UserType.TUTOR;
            publicUserData.DisplayName           = MyRegistrationInfo.FirstName.Trim() + " " + MyRegistrationInfo.LastName.Trim();
            publicUserData.SearchableDisplayName = MyRegistrationInfo.FirstName.Trim().ToLower() + MyRegistrationInfo.LastName.Trim().ToLower();
            publicUserData.BaseUserId            = user.ObjectId;
            publicUserData.Tutor = tutor;
            string path = HttpContext.Current.Server.MapPath("~/Images/default_prof_pic.png");

            byte[] pic = File.ReadAllBytes(path);
            publicUserData.ProfilePic            = new ParseFile("default-profile-pic", pic);
            publicUserData.ACL                   = new ParseACL();
            publicUserData.ACL.PublicReadAccess  = true;
            publicUserData.ACL.PublicWriteAccess = false;
            publicUserData.ACL.SetWriteAccess(user, true);
            publicUserData.ACL.SetRoleReadAccess(adminRole, true);
            publicUserData.ACL.SetRoleWriteAccess(adminRole, true);
            await publicUserData.SaveAsync();

            user["registrationTestScore"] = registrationTestScore;
            user.ACL = new ParseACL(user);
            user.ACL.SetRoleReadAccess(adminRole, true);
            user["publicUserData"] = publicUserData;
            //user.phoneNumber = tbPhoneNumber.Text;
            //user.zipCode = tbZipCode.Text;
            //user.address = tbStreetAddress.Text;
            //user.address2 = tbAddress2.Text;
            //user.city = tbCity.Text;
            //user.state = ddState.SelectedValue;
            await user.SaveAsync();
        }