public async Task <IActionResult> Post([FromBody] JStudent student_)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            byte[] saltNumber = new byte[10];
            rngCsp.GetBytes(saltNumber);
            String  saltString = System.Text.Encoding.Default.GetString(saltNumber);
            String  password   = BCrypt.Net.BCrypt.HashPassword(saltString + "pass");
            Student student    = new Student()
            {
                Nume            = student_.nume,
                InitialaParinte = student_.initiale,
                NumarMatricol   = int.Parse(student_.nrMatricol),
                NumarTelefon    = student_.telefon,
                Active          = true,
                An        = "1",
                Email     = student_.email,
                Generatie = DateTime.Now.Year.ToString(),
                UserType  = UserType.STUDENT,
                Username  = student_.username,
                Password  = password,
                Salt      = saltString,
                CNP       = student_.cnp,
                Prenume   = student_.prenume
            };

            _context.Student.Add(student);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetStudent", new { id = student.Username }, student));
        }
示例#2
0
        protected void btnMakeStudentOfTheMonth_Click(object sender, EventArgs e)
        {
            JStudent student = new JStudent();

            if (student.StudentOfTheMonth(txtstudentofthemonth.Text) == true)
            {
                Response.Write("<script>alert('Record successfully updated.')</script>");
            }
            else
            {
                Response.Write("<script>alert('Error occur during updating information.')</script>");
            }
        }