Exemplo n.º 1
0
        public ContentResult GetStudents()
        {
            var students = SelectStudent.SelectAvailable();

            return(new ContentResult
            {
                Content = JsonSerializer.Serialize(students),
                ContentType = "application/json",
                StatusCode = (int)HttpStatusCode.OK
            });
        }
Exemplo n.º 2
0
        public ContentResult GetStudentsFor(GroupModel group)
        {
            var students = SelectStudent.Select(group);

            return(new ContentResult
            {
                Content = JsonSerializer.Serialize(students),
                ContentType = "application/json",
                StatusCode = (int)HttpStatusCode.OK
            });
        }
Exemplo n.º 3
0
        private static void RunDemo(SqlConnection connection)
        {
            var selectStudent = new SelectStudent();
            var insertStudent = new InsertUser();
            var deleteStudent = new DeleteUser();
            var elev          = new Student
            {
                Name = "",
                Path = "[dbo].[Student]"
            };

            Console.Write("You can Delete, Insert, Update or Select a user {Template: [Command] [User]}: ");
            var input = Console.ReadLine();

            if (!string.IsNullOrEmpty(input))
            {
                var command = input.Split(' ');
                switch (command[0].ToLower())
                {
                case "delete":
                    elev.Name = command[1];
                    deleteStudent.DeleteUser(connection, elev.Name, elev.Path);
                    Console.WriteLine($"Deleting user {elev.Name}...");
                    break;

                case "insert":
                    elev.Name = command[1];
                    insertStudent.AddUser(connection, elev.Name, elev.Path);
                    Console.WriteLine($"Creating new user {elev.Name}...");
                    break;

                case "update":
                    break;

                case "select":
                    break;

                default:
                    Console.WriteLine("Invalid input, please try again..." + Environment.NewLine);
                    break;
                }
            }
            else
            {
                Console.WriteLine("Invalid input, please try again..." + Environment.NewLine);
            }
            Console.WriteLine("Outputting list of all students: ");
            var students = selectStudent.GetAllStudents(connection);

            foreach (var student in students)
            {
                Console.WriteLine(student);
            }
        }
Exemplo n.º 4
0
        private static void RunDemo(SqlConnection connection)
        {
            var selectStudent = new SelectStudent();

            Console.WriteLine("Kjører GetStudent");
            Console.WriteLine(selectStudent.GetStudent(connection, 2));
            Console.WriteLine("Kjører GetAllStudents");
            var allStudents = selectStudent.GetAllStudent(connection);

            foreach (var student in allStudents)
            {
                Console.WriteLine(student);
            }
        }