Пример #1
0
        internal void AddStudent()
        {
            Console.Write("Please provide a student id: ");
            var studentID = Console.ReadLine();

            while (!Validate.ValidStudentId(studentID))
            {
                Console.WriteLine("Student id violated standard format 's3' prefix, 6 digits suffix. Please retry as (s3xxxxxx): ");
                studentID = Console.ReadLine();
            }

            Console.Write("Please provide first name: ");
            var firstName = Console.ReadLine();

            while (!Validate.ValidNameString(firstName))
            {
                Console.WriteLine("First name does not allow space and number");
                firstName = Console.ReadLine();
            }

            Console.Write("Please provide middle name: ");
            var middleName = Console.ReadLine();

            while (!Validate.ValidNameString(middleName))
            {
                Console.WriteLine("Middle name does not allow space and number");
                middleName = Console.ReadLine();
            }

            Console.Write("Please provide last name: ");
            var lastName = Console.ReadLine();

            while (!Validate.ValidNameString(lastName))
            {
                Console.WriteLine("Last name does not allow space and number");
                lastName = Console.ReadLine();
            }

            bool added = studentController.CreateStudent(studentID, firstName, middleName, lastName);

            if (added)
            {
                Console.WriteLine("\nCongratulation! You added a new student has id: " + studentID);
            }
            else
            {
                Console.WriteLine("\nSorry! You failed to add a student " + studentID);
            }
            Console.WriteLine("Press any key to continue...");
            Console.ReadLine();
        }
Пример #2
0
        public static void GenerateMenu()
        {
            while (true)
            {
                Console.WriteLine("1. Create Student");
                Console.WriteLine("2. List Student");
                Console.WriteLine("0. Exit");
                int opt = Convert.ToInt32(Console.ReadLine());
                switch (opt)
                {
                case 1:
                    st.CreateStudent();
                    GenerateMenu();
                    break;

                case 2:
                    st.PrintListStudent();
                    GenerateMenu();
                    break;

                case 3:
                    Environment.Exit(-1);
                    break;
                }
            }
        }
Пример #3
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            var student  = new Student();
            var studentC = new StudentController();

            if (StudentId > 0)
            {
                student             = studentC.GetStudent(StudentId);
                student.StudentName = txtStudentFName.Text + " " + txtStudentLName.Text;
            }
            else
            {
                student = new Student()
                {
                    StudentName = txtStudentFName.Text + " " + txtStudentLName.Text
                };
            }

            if (StudentId > 0)
            {
                studentC.UpdateStudent(student);
            }
            else
            {
                studentC.CreateStudent(student);
            }

            Response.Redirect(DotNetNuke.Common.Globals.NavigateURL());
        }
Пример #4
0
        static void Main(string[] args)
        {
            StudentController studentController = new StudentController();
            List <Student>    students          = new List <Student>();
            Student           student           = new Student();
            bool quit = false;

            while (!quit)
            {
                Menu();
                byte choose = Byte.Parse(Console.ReadLine());
                switch (choose)
                {
                case 1:
                    student = studentController.CreateStudent();
                    students.Add(student);
                    break;

                case 2:
                    studentController.PrintListStudent(students);
                    break;

                case 0:
                    quit = true;
                    break;

                default: Console.WriteLine("Unavailable function, choose againt!"); break;
                }
            }
        }
Пример #5
0
        public static void Main(string[] args)
        {
            int choice;

            do
            {
                Console.WriteLine("------------------ THE  STUDENT MANAGEMENT SYSTEM   ------------------");
                Console.WriteLine("1.CREATE STUDENT.");
                Console.WriteLine("2.PRINT STUDENT.");
                Console.WriteLine("0.Exit");
                do
                {
                    Console.WriteLine("Choose funtion (0/1/2) : ");
                    choice = Convert.ToInt32(Console.ReadLine());
                    if (choice < 0 || choice > 2)
                    {
                        Console.WriteLine("Error ! Please choose again !");
                    }
                } while (choice < 0 || choice > 2);
                switch (choice)
                {
                case 1:
                    st.CreateStudent();
                    break;

                case 2:
                    st.printListStudent();
                    break;

                case 0:
                    return;
                }
            } while (choice != 0);
        }
Пример #6
0
        static void Main(string[] args)
        {
            bool start      = true;
            var  controller = new StudentController();

            while (start)
            {
                GenerateMenu();
                int choice = Convert.ToInt16(Console.ReadLine());
                switch (choice)
                {
                case 1:
                    controller.CreateStudent();
                    break;

                case 2:
                    controller.PrintListStudent();
                    break;

                case 3:
                    start = false;
                    break;
                }
            }
        }
Пример #7
0
        private void input()
        {
            Console.WriteLine("input New Student: ");
            Console.WriteLine("input RollNumber: ");
            RollNumber = Console.ReadLine();
            Console.WriteLine("input FullName: ");
            FullName = Console.ReadLine();
            Console.WriteLine("input Birthday: ");
            Birthday = DateTime.Parse(Console.ReadLine());
            Console.WriteLine("input Email: ");
            Email = Console.ReadLine();
            Console.WriteLine("input Phone: ");
            Phone = Console.ReadLine();
            Console.WriteLine("input Status (1 is Active; 0 is Deactive: ");
            Status = int.Parse(Console.ReadLine());
            while (Status > 1 && Status < 0)
            {
                Console.WriteLine("input Status (1 is Active; 0 is Deactive: ");
                Status = int.Parse(Console.ReadLine());
            }
            ;
            Student student = new Student();

            student = controller.CreateStudent(RollNumber, FullName, Birthday, Email, Phone, Status);
            students.Add(student);
        }
Пример #8
0
        public static void GenerateMenu()
        {
            List <Student>    students = new List <Student>();
            StudentController stc      = new StudentController();
            int choice;

            do
            {
                Console.WriteLine("----------------Menu-----------------");
                Console.WriteLine("1. Create New Student");
                Console.WriteLine("2. View list of Students");
                Console.WriteLine("3. Exit");
                Console.WriteLine("-------------------------------------");
                Console.Write("Enter your choice:");
                choice = Convert.ToInt32(Console.ReadLine());

                switch (choice)
                {
                case 1:
                    Student st = stc.CreateStudent();
                    students.Add(st);
                    break;

                case 2:
                    stc.PrintListStudent(students);
                    break;

                default:
                    break;
                }
            } while (choice != 3);
        }
Пример #9
0
        public void Delete_ExistingStudent_OkResult()
        {
            var controller = new StudentController(_logger, _studentService);
            var student    = new Entities.Models.Student
            {
                Id             = new Guid("f7afefa9-2cc6-4ea9-901d-d99e227a12de"),
                FirstName      = "Bart",
                LastName       = "Simpson",
                DocumentType   = Entities.Models.EDocumentType.CC,
                DocumentNumber = "97654315",
                Address        = "Springfield 123",
                Email          = "*****@*****.**",
                City           = "Springfield",
                PhoneNumber    = "7654321",
                Birth          = new DateTime(1950, 11, 1)
            };

            var data = controller.CreateStudent(student);

            Assert.IsType <CreatedAtRouteResult>(data as CreatedAtRouteResult);

            var deleteResult = controller.DeleteStudent(student.Id);

            Assert.IsType <NoContentResult>(deleteResult);
        }
Пример #10
0
        static void Main(string[] args)
        {
            List <Student> lsStudents = new List <Student>();

            int choice = 0;

            do
            {
                choice = GenerateMenu();
                switch (choice)
                {
                case 1:
                    StudentController controller = new StudentController();
                    controller.CreateStudent();
                    lsStudents.Add(controller);
                    break;

                case 2:
                    foreach (StudentController sc in lsStudents)
                    {
                        sc.PrintListStudent(lsStudents);
                    }
                    break;

                default:
                    break;
                }
            } while (choice != 3);



            Console.ReadLine();
        }
Пример #11
0
        public string CreateStudent(string StuName, string StuFamilyName, string StuFatherName, string StuGFName, string stuPhoneNumber, string stuUName, string ClassID, string CreatedBy)
        {
            //string res = _manager.CreateStudent(StuName, StuFamilyName, StuFatherName, StuGFName, stuPhoneNumber, stuUName, ClassID, CreatedBy);
            string res = studentController.CreateStudent(StuName, StuFamilyName, StuFatherName, StuGFName, stuPhoneNumber, stuUName, ClassID, CreatedBy);


            return(res);
        }
Пример #12
0
        static void Main(string[] args)
        {
            List <StudentsModel> lst = new List <StudentsModel>();
            StudentController    stc = new StudentController();
            int check;

            GenerateMenu();
            while (true)
            {
                Console.WriteLine("Nhap lua chon:  ");
                check = int.Parse(Console.ReadLine());
                switch (check)
                {
                case 1:
                    Console.WriteLine("1.Them moi sinh vien");
                    var a = stc.CreateStudent();
                    lst.Add(a);
                    Console.WriteLine("Them moi thanh cong");
                    break;

                case 2:
                    Console.WriteLine("2. Danh sach sv");
                    stc.PrintListStudent(lst);
                    break;

                case 3:
                    //System.Application.Exit;
                    Environment.Exit(0);
                    break;

                default:
                    Console.WriteLine("Nhap lai lua chon");
                    break;
                }
            }

            //DateTime time = DateTime.Now.AddDays(-61);
            //bool a = st.IsNewStudent(time);
            //if (a)
            //{
            //    Console.WriteLine("Ban la hs moi");
            //    Console.ReadLine();
            //}
            //else
            //{
            //    Console.WriteLine("Ban la hs cu");
            //    Console.ReadLine();

            //}
            //StudentController stc = new StudentController();
            // stc.CreateStudent();
            //Console.ReadLine();
        }
Пример #13
0
        static void Main(string[] args)
        {
            StudentController studentController = new StudentController();

            studentController.CreateStudent(new Student(
                                                "T012",
                                                "Le Huy Hai",
                                                new DateTime(1998, 1, 6),
                                                "*****@*****.**",
                                                "0931234567",
                                                new DateTime(2019, 4, 20),
                                                Student.StudentStatus.Active
                                                ));
            while (true)
            {
                GenerateMenu();
                var choice = Console.ReadLine();
                while (!Int32.TryParse(choice, out int result))
                {
                    Console.WriteLine("Not a choice. Re-enter:");
                    choice = Console.ReadLine();
                }
                switch (Int32.Parse(choice))
                {
                case 1:
                    studentController.CreateStudentManually();
                    break;

                case 2:
                    studentController.PrintListStudent();
                    break;

                case 3:
                    Console.WriteLine("\nEnter student's roll number:");
                    studentController.ChangeStudentStatus(Console.ReadLine());
                    break;

                case 4:
                    Console.WriteLine("\nEnter student's roll number:");
                    studentController.CheckNewStudent(Console.ReadLine());
                    break;

                case 5:
                    Console.WriteLine("\nProgram exited successfully.");
                    return;

                default:
                    Console.WriteLine("Not a choice");
                    break;
                }
            }
        }
Пример #14
0
        private static void GenerateMenu()
        {
            var studentController = new StudentController();

            while (true)
            {
                Console.Clear();
                Console.WriteLine("===================STUDENT MANAGER================");
                Console.WriteLine("1. Add Student");
                Console.WriteLine("2. Show List Student");
                Console.WriteLine("3. Update Student");
                Console.WriteLine("4. Delete Student");
                Console.WriteLine("5. Exit");
                Console.WriteLine("===================================================");
                Console.WriteLine("Please enter your choice: ");
                var choice = int.Parse(Console.ReadLine());
                switch (choice)
                {
                case 1:
                    studentController.CreateStudent();
                    break;

                case 2:
                    studentController.ShowList();
                    break;

                case 3:
                    studentController.UpdateStudent();
                    break;

                case 4:
                    studentController.DeleteStudent();
                    break;

                case 5:
                    Console.WriteLine("Close application!");
                    break;

                default:
                    Console.WriteLine("Please choice from 1 to 5!");
                    break;
                }
                if (choice == 5)
                {
                    Console.WriteLine("See you again!");
                    break;
                }
                Console.WriteLine("Press any key to continue!");
                Console.Read();
            }
        }
Пример #15
0
        public void CreateStudent_ReturnsCreatedStudent()
        {
            //Arrange
            var studentToBeCreated = this.GetDefaultStudent();

            _studentService.Setup(x => x.New(studentToBeCreated))
            .Returns(studentToBeCreated);
            //Act
            ActionResult <Student> result = _studentControlller.CreateStudent(studentToBeCreated);

            //Assert
            Assert.IsType <ActionResult <Student> >(result);

            Assert.Equal(((CreatedAtRouteResult)result.Result).Value, studentToBeCreated);
        }
Пример #16
0
        public static void GenerateMenu()
        {
            var stc = new StudentController();

            while (true)
            {
                Console.OutputEncoding = Encoding.Unicode;
                Console.InputEncoding  = Encoding.Unicode;
                Console.WriteLine("Nhập lựa chọn của bạn ");
                Console.WriteLine("=====================");
                Console.WriteLine("Menu");
                Console.WriteLine("=====================");
                Console.WriteLine("1 -Tạo Mới Sinh Viên");
                Console.WriteLine("2 -Hiển Thị Danh Sách Sinh Viên");
                Console.WriteLine("3 -EXIT");

                int choice = Convert.ToInt32(Console.ReadLine());
                while (choice < 1 || choice > 3)
                {
                    Console.WriteLine("Lựa chọn không hợp lệ  vui lòng chọn lại");
                    Console.WriteLine("=====================");
                    Console.WriteLine("Menu");
                    Console.WriteLine("=====================");
                    Console.WriteLine("1 -Tạo Mới Sinh Viên");
                    Console.WriteLine("2 -Hiển Thị Danh Sách Sinh Viên");
                    Console.WriteLine("3 -EXIT");
                    choice = Convert.ToInt32(Console.ReadLine());
                }

                switch (choice)
                {
                case 1:
                    stc.CreateStudent();
                    break;

                case 2:

                    stc.PrintListStudent(stc.student);
                    break;

                default:
                    System.Environment.Exit(0);

                    break;
                }
            }
        }
Пример #17
0
        static void GenerateMenu()
        {
            var listStudent = new List <Student>();
            var controller  = new StudentController();

            while (true)
            {
                Console.WriteLine("\t Menu");

                Console.WriteLine("1. Them sinh vien moi.");

                Console.WriteLine("2. Hien thi danh sach sinh vien.");

                Console.WriteLine("3. Thoat.");

                int choose = Convert.ToInt32(Console.ReadLine());

                switch (choose)
                {
                case 1:
                    Console.WriteLine("Them moi sinh vien");
                    var student = controller.CreateStudent();
                    listStudent.Add(student);
                    break;

                case 2:
                    Console.WriteLine("Danh sach sinh vien : ");
                    controller.PrintListStudent(listStudent);
                    break;

                case 3:
                    Console.WriteLine("Goodbye!!!");
                    break;

                default:
                    Console.WriteLine("Choose = 1, 2 or 3");
                    break;
                }
                if (choose == 3)
                {
                    break;
                }
            }
        }
Пример #18
0
        private static void GenerateMenu()
        {
            var list       = new List <Student>();
            var controller = new StudentController();

            while (true)
            {
                Console.WriteLine("\t Menu");
                Console.WriteLine("1. Thêm mới.");
                Console.WriteLine("2. Hiển thị danh sách.");
                Console.WriteLine("0. Exist.");
                int choice = Convert.ToInt32(Console.ReadLine());
                switch (choice)
                {
                case 1:
                    Console.WriteLine("Thêm mới sinh viên");
                    var student = controller.CreateStudent();
                    list.Add(student);
                    break;

                case 2:
                    Console.WriteLine("Danh sách sinh viên");
                    controller.PrintListStudent(list);
                    break;

                case 0:
                    Console.WriteLine("Goodbye.");
                    break;

                default:
                    Console.WriteLine("Invalid choice.");
                    break;
                }
                if (choice == 0)
                {
                    break;
                    ;
                }
            }
            Console.ReadLine();
        }
Пример #19
0
        public void Create_StudentWithValidData_OkResult()
        {
            var controller = new StudentController(_logger, _studentService);
            var student    = new Entities.Models.Student
            {
                Id             = new Guid("e47c0cb5-05b6-437d-b40f-f2c5b5a08385"),
                FirstName      = "Homero",
                LastName       = "Simpson",
                DocumentType   = Entities.Models.EDocumentType.CC,
                DocumentNumber = "1245687",
                Address        = "Springfield 123",
                Email          = "*****@*****.**",
                City           = "Springfield",
                PhoneNumber    = "7654321",
                Birth          = new DateTime(1950, 11, 1)
            };

            var data = controller.CreateStudent(student);

            Assert.IsType <CreatedAtRouteResult>(data as CreatedAtRouteResult);
        }
Пример #20
0
        public void CreateStudent()
        {
            // Arrange
            var studentDto = new StudentDto
            {
                BirthDate  = DateTime.UtcNow,
                FirstName  = "Jane",
                LastName   = "Doe",
                MiddleName = "A"
            };
            var student = _mapper.Map <Student>(studentDto);

            Mock.Get(_repositoryWrapper.Student).Setup(x => x.CreateStudent(student));
            Mock.Get(_repositoryWrapper.Student).Setup(x => x.GetStudentById(student.Id)).ReturnsAsync(student);
            var controller = new StudentController(_loggerManager, _mapper, _repositoryWrapper);
            // Act
            var actionResult = controller.CreateStudent(studentDto).Result;
            // Assert
            var okObjectResult = actionResult as OkObjectResult;

            Assert.IsNotNull(okObjectResult);
        }
Пример #21
0
        static void GenerateMenu()
        {
            List <Student> studentList       = new List <Student>();
            var            studentController = new StudentController();
            var            option            = 1;
            var            isContinue        = true;

            do
            {
                Console.WriteLine("----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------");
                Console.WriteLine("Menu:");
                Console.WriteLine("1. Create new student");
                Console.WriteLine("2. Show student list");
                Console.WriteLine("3. Exit");
                Console.WriteLine("----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------");
                Console.WriteLine("Select menu item: ");
                option = int.Parse(Console.ReadLine());
                switch (option)
                {
                case 1:
                    var student = studentController.CreateStudent();
                    studentList.Add(student);
                    break;

                case 2:
                    studentController.PrintListStudent(studentList);
                    break;

                case 3:
                    Console.WriteLine("Goodbye !!");
                    isContinue = false;
                    break;

                default:
                    Console.WriteLine("Menu item does not exist, please choose again");
                    break;
                }
            } while (isContinue);
        }
        public void GivenCreatingStudent_WhenPosting_ThenCorrespondingStudentIsCreated()
        {
            // Arrange

            var testStudent = new Student("OliCreationTest", "test");
            CreateStudentMessage      request = null;
            CreateStudentReplyMessage reply   = null;

            var queryCountWrapper = new Mock <IQueryCountWrapper>();

            queryCountWrapper.SetupGet(qcw => qcw.QueryCount).Returns(0);

            var bus = new Mock <IBus>(MockBehavior.Strict);

            bus
            .Setup(b => b.SendRequest
                   <CreateStudentMessage, CreateStudentReplyMessage>
                       (It.IsAny <string>(), It.IsAny <CreateStudentMessage>(), null, It.IsAny <int>()))
            .Returns <string, CreateStudentMessage, Dictionary <string, string>, int>(
                (endpoint, message, headers, timeout) =>
            {
                request = message;
                reply   = new CreateStudentReplyMessage(message.CorrelationId);
                return(reply);
            });

            var claimsHelper = new Mock <IClaimsHelper>(MockBehavior.Strict);
            var controller   = new StudentController(bus.Object, claimsHelper.Object, queryCountWrapper.Object);

            // Act
            var result         = controller.CreateStudent(testStudent);
            var okObjectResult = result as AcceptedResult;

            // Assert

            Assert.NotNull(okObjectResult);
        }
Пример #23
0
        static void Main(string[] args)
        {
            StudentController controller = new StudentController();
            bool running = true;

            while (running)
            {
                Console.WriteLine("Enter your choice of operation\n--------------------------------------\n" +
                                  "1.Create Student\n" +
                                  "2.Update Student\n" +
                                  "3.Delete Student\n" +
                                  "4.List all students\n" +
                                  "5.Exit\n------------------------------------\n");
                int choice = Convert.ToInt32(Console.ReadLine());
                switch (choice)
                {
                case 1:
                    Student s = new Student();
                    Console.WriteLine("Enter student information\n-------------------------------------------\n");
                    Console.WriteLine("Enter student id\t");
                    s.StudentId = Console.ReadLine();
                    Console.WriteLine("Enter the students firstname");
                    s.firstName = Console.ReadLine();
                    Console.WriteLine("Enter students last name");
                    s.lastname = Console.ReadLine();
                    Console.WriteLine("Enter student Email");
                    s.email = Console.ReadLine();
                    controller.CreateStudent(s);
                    break;

                case 2:
                    Student n = new Student();
                    Console.WriteLine("Enter new student information\n-------------------------------------------\n");
                    Console.WriteLine("Enter id of student to be updated\t");
                    n.StudentId = Console.ReadLine();
                    Console.WriteLine("Enter the students new  firstname\t");
                    n.firstName = Console.ReadLine();
                    Console.WriteLine("Enter students new  last name\t");
                    n.lastname = Console.ReadLine();
                    Console.WriteLine("Enter students new Email\t");
                    n.email = Console.ReadLine();
                    controller.UpdateStudent(n);
                    break;

                case 3:
                    Console.WriteLine("Enter student id o fstudent to be deleted\t");
                    string studentIdtoBeDeleted = Console.ReadLine();
                    controller.DeleteStudent(studentIdtoBeDeleted);
                    break;

                case 4:
                    List <Student> students = new List <Student>();
                    students = controller.ListStudents();
                    Console.WriteLine("StudentId\t\t\t\tFirstname\t\t\t\tLastName\t\t\t\t\tEmail\n-----------------\t\t\t-----------------\t\t\t-----------------\t\t\t-----------------\n");
                    foreach (Student a   in students)
                    {
                        Console.WriteLine(a.StudentId + "\t\t\t\t\t" + a.firstName + "\t\t\t\t\t" + a.lastname + "\t\t\t\t\t" + a.email);
                    }
                    break;

                case 5:
                    running = false;
                    break;

                default:
                    Console.WriteLine("Invalid Input choice");
                    break;
                }
            }
        }