Exemplo n.º 1
0
        private async void retrieveStudentButton_Click(object sender, EventArgs e)
        {
            if (firstName.Text.Length == 0 || middleName.Text.Length == 0 || lastName.Text.Length == 0)
            {
                MessageBox.Show("The name fields cannot be empty!");
                return;
            }

            List <FullStudent> students = await GetAllFullStudents();

            Func <FullStudent, bool> predicate = x => x.FirstName == firstName.Text && x.LastName == lastName.Text && x.MiddleName == middleName.Text;

            try
            {
                FullStudent fullStudent = students.First(predicate);

                if (fullStudent != null)
                {
                    string       fullStudentJSON  = JsonConvert.SerializeObject(fullStudent);
                    BasicStudent basicStudent     = StudentMapper.FullStudentToBasicStudent(fullStudent);
                    string       basicStudentJSON = JsonConvert.SerializeObject(basicStudent);

                    basicStudentTextBox.Text = basicStudentJSON;
                    fullStudentTextBox.Text  = fullStudentJSON;
                }
            } catch (Exception exp)
            {
                MessageBox.Show(exp.Message);
            }
        }
Exemplo n.º 2
0
        string CalculateCurrentFullStudentHash(FullStudent currentFullStudent)
        {
            BasicStudent currentBasicStudent = StudentMapper.FullStudentToBasicStudent(currentFullStudent);

            string currentBasic     = JsonConvert.SerializeObject(currentBasicStudent);
            string currentBasicHash = Hash.GetHashString(currentBasic);

            string currentSalt     = currentFullStudent.Salt;
            string currentSaltHash = Hash.GetHashString(currentSalt);

            string fullHash = Hash.GetHashString(currentBasicHash + currentSaltHash);

            return(fullHash);
        }