static void CreateStudent()
        {
            int    id;
            string idTry, name, subject, sex;

            while (true)
            {
                Console.WriteLine("Please Enter The New Student ID: ");
                idTry = Console.ReadLine();
                try
                {
                    id = Int32.Parse(idTry);
                    break;
                }
                catch (Exception e)
                {
                    Console.WriteLine("Please Enter An Int! ");
                    continue;
                    throw;
                }
            }

            Console.WriteLine("Please Enter The New Student Name: ");
            name = Console.ReadLine();
            Console.WriteLine("Please Enter The New Student Subject: ");
            subject = Console.ReadLine();
            Console.WriteLine("Please Enter The New Student Sex: ");
            sex = Console.ReadLine();

            isb.CreateStudent(id, name, subject, sex);
        }
Esempio n. 2
0
        public IActionResult CreateStudent([FromBody] StudentInputDto student)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            if (_studentBusiness.CreateStudent(student))
            {
                _students.Add(student);
            }

            return(Json(_students));
        }