Ejemplo n.º 1
0
        public void Exe()
        {
            Console.Clear();
            Console.WriteLine("Add Student");
            Console.WriteLine(ConsoleIO.Bar);
            Console.WriteLine("");

            Student s1 = new Student();

            s1.FirstName = ConsoleIO.GetRequiredStringFromUser("First Name: ");
            s1.LastName  = ConsoleIO.GetRequiredStringFromUser("Last Name: ");
            s1.Major     = ConsoleIO.GetRequiredStringFromUser("Major: ");
            s1.GPA       = ConsoleIO.GetRequiredDecmialFromUser("GPA: ");

            Console.WriteLine("");
            ConsoleIO.PrintHeader();
            Console.WriteLine(ConsoleIO.StudentLineFormat, s1.LastName + ", " + s1.FirstName, s1.Major, s1.GPA);

            Console.WriteLine("");
            if (ConsoleIO.GetYesNoFromUser("Add the following information (Y/N)") == "Y")
            {
                studentRepository.Add(s1);
                Console.WriteLine("Student added");
                Console.WriteLine("Press any key to continue...");
                Console.ReadKey();
            }
            else
            {
                Console.WriteLine("Action cancelled");
                Console.WriteLine("Press any key to continue....");
                Console.ReadKey();
            }
        }
Ejemplo n.º 2
0
        public void Execute()
        {
            Console.Clear();
            Console.WriteLine("Add Student");
            Console.WriteLine(ConsoleIO.SeparatorBar);
            Console.WriteLine("");

            Student newStudent = new Student();

            newStudent.FirstName = ConsoleIO.GetRequiredStringFromUser("First Name: ");
            newStudent.LastName  = ConsoleIO.GetRequiredStringFromUser("Last Name: ");
            newStudent.Major     = ConsoleIO.GetRequiredStringFromUser("Major: ");
            newStudent.GPA       = ConsoleIO.GetRequiredDecimalFromUser("GPA: ");


            Console.WriteLine();
            ConsoleIO.PrintHeader();
            Console.WriteLine(ConsoleIO.StudentLineFormat, newStudent.LastName + ", " + newStudent.FirstName, newStudent.Major, newStudent.GPA);

            Console.WriteLine();
            if (ConsoleIO.GetYesNoFromUser("Add the following information") == "Y")
            {
                StudentRepo repo = new StudentRepo(Settings.FilePath);
                repo.Add(newStudent);
                Console.WriteLine("Student Added");
                Console.WriteLine("Press any key to continue...");
                Console.ReadKey();
            }
            else
            {
                Console.WriteLine("Action cancelled");
                Console.WriteLine("Press any key to continue...");
                Console.ReadKey();
            }
        }
 public ActionResult AddStudent([FromBody] Student s)
 {
     if (StudentRepo.Add(s))
     {
         return(Ok("Student has been successfully added"));
     }
     return(BadRequest("The student has already been added"));
 }
 public IActionResult AddStudent([FromBody] StudentModel.StudentModel student)
 {
     if (StudentRepo.Add(student))
     {
         return(Ok($"{student.name} has been successfully added."));
     }
     return(BadRequest("The student has already been added."));
 }
Ejemplo n.º 5
0
        public void Add(Models.Student.AddViewModel addViewModel)
        {
            Student student = new Student()
            {
                RollNumber  = addViewModel.RollNumber,
                Name        = addViewModel.Name,
                CGPI        = addViewModel.CGPI,
                Location    = addViewModel.Location,
                DateOfBirth = addViewModel.DateOfBirth
            };

            repo.Add(student);
        }
Ejemplo n.º 6
0
        public ActionResult Add(StudentVM data)
        {
            Student std = new Student();

            std.FirstName = data.FirstName;
            std.LastName  = data.LastName;
            std.Email     = data.Email;
            std.Classrooms.Add(clsRepo.GetById(data.ClassroomID));
            std.IsActive    = true;
            std.UserName    = data.FirstName.Substring(0, 2).ToLower() + "." + data.LastName.ToLower();
            std.Password    = data.FirstName.Substring(0, 2).ToLower() + "." + data.LastName.ToLower() + "123";
            std.CreatedDate = DateTime.UtcNow;

            stdRepo.Add(std);
            return(RedirectToAction("StudentList", "AdminStudent"));
        }
Ejemplo n.º 7
0
        public void CanAddStudents()
        {
            StudentRepo repo       = new StudentRepo(_filePath);
            Student     newStudent = new Student();

            newStudent.FirstName = "Testy";
            newStudent.LastName  = "Tester";
            newStudent.Major     = "Research";
            newStudent.GPA       = 3.2M;
            repo.Add(newStudent);

            List <Student> students = repo.List();

            Assert.AreEqual(5, students.Count());

            Student check = students[4];

            Assert.AreEqual("Testy", check.FirstName);
            Assert.AreEqual("Tester", check.LastName);
            Assert.AreEqual("Research", check.Major);
            Assert.AreEqual(3.2M, check.GPA);
        }
Ejemplo n.º 8
0
 public void SignupStudent(Student s)
 {
     StudentRepo.Add(s);
 }