Exemple #1
0
        public static void Main(string[] args)
        {
            var studentDb = new StudentSystemData();

            var newResource = new Resource {
                Link = "www.abv.bg", Name = "Email", Type = ResourceType.Other
            };

            studentDb.Resources.Add(newResource);

            Student student = new Student
            {
                FirstName   = "Ta Pepelqqq",
                LastName    = "Ne vyrvi",
                Birthday    = new DateTime(1825, 02, 02),
                PhoneNumber = "123469899"
            };

            studentDb.Students.Add(student);

            Course course = new Course {
                Description = "Za Strugari", Name = "Strug mania", Price = 1.1M, EndDate = new DateTime(2016, 12, 1), StartDate = DateTime.Now
            };

            course.Resources.Add(newResource);
            studentDb.Courses.Add(course);

            studentDb.SaveChanges();

            var studentsHomeworks = GetStudentsWithHomeworks(studentDb);

            foreach (var studentHomeworks in studentsHomeworks)
            {
                Console.WriteLine(studentHomeworks.FirstName + " " + studentHomeworks.LastName);

                var homeworks = studentHomeworks.Homeworks;
                foreach (var homework in homeworks)
                {
                    Console.WriteLine(" " + homework.CourseName + "-" + homework.SentOn.Date);
                }

                Console.WriteLine();
            }


            var coursesWithResources = GetCoursesWithResources(studentDb);

            foreach (var courseWithResources in coursesWithResources)
            {
                Console.WriteLine(courseWithResources.Name);

                var resources = courseWithResources.Resources;
                foreach (var resource in resources)
                {
                    Console.WriteLine(" " + resource.Name + "-" + resource.Link);
                }

                Console.WriteLine();
            }
        }
Exemple #2
0
        private static int AddCourseMaterial(StudentSystemData data)
        {
            Material material = new Material
            {
                Name         = "JSAdvanced Simulating OOP Homework",
                Link         = "https://softuni.bg/downloads/svn/javascript-oop/March-2015/2.%20Simulating-OOP-in-JavaScript-Homework.docx",
                MaterialType = MaterialType.HomeworkAssignment
            };

            data.Materials.Add(material);
            return(data.SaveChanges());
        }
Exemple #3
0
        private static int AddStudent(StudentSystemData data)
        {
            Student student = new Student
            {
                Name             = "Gergana Gencheva",
                RegistrationDate = DateTime.Now,
                BirthDay         = new DateTime(1825, 02, 02),
                PhoneNumber      = "123469899"
            };

            data.Students.Add(student);
            return(data.SaveChanges());
        }
        public static void Main()
        {
            var data = new StudentSystemData();

            IQueryable<Course> courses = data.Courses.All();

            foreach (var course in courses)
            {
                Console.WriteLine(course.Name);
            }

            data.Courses.Add(new Course
            {
                Name = "Repo Pattern",
                Description = "Cool"
            });

            data.SaveChanges();
        }
Exemple #5
0
        private static void Main()
        {
            var data = new StudentSystemData();

            var hw = new Homework
            {
                FileName = "Domestic rakia",
                Deadline = new DateTime(2014, 08, 31),
                TimeSent = new DateTime(2014, 08, 29)
            };

            var student = new Student
            {
                FirstName   = "Pesho",
                LastName    = "Piandeto",
                PhoneNumber = "082569875",
                Homeworks   = new List <Homework> {
                    hw
                }
            };

            data.Homeworks.Add(hw);

            data.Students.Add(student);

            data.Courses.Add(new Course
            {
                Name        = "Kukuruz seller",
                Description = "Corn, corn, corn",
                Students    = new List <Student> {
                    student
                }
            });

            data.SaveChanges();
        }
Exemple #6
0
        private static int AddCourseWithMaterials(StudentSystemData data)
        {
            Course course = new Course
            {
                Name        = "JS Advanced",
                Description = "JavaScript course for advanced programmers",
                StartDate   = new DateTime(2015, 02, 27),
                EndDate     = new DateTime(2015, 04, 21),
                Price       = 0m
            };

            Material material = new Material
            {
                Name         = "JSAdvanced Function Expressions Demo",
                Link         = "https://github.com/SoftUni/Advanced-JavaScript/tree/master/1.%20Functions-and-Function-Expressions",
                MaterialType = MaterialType.CodeStubs
            };

            data.Materials.Add(material);
            course.Materials.Add(material);
            //material.Courses.Add(course);
            data.Courses.Add(course);
            return(data.SaveChanges());
        }
        public static void Main()
        {
            var data = new StudentSystemData();

            var students = data.Students.All();

            var count = 1;

            foreach (var student in students)
            {
                student.FirstName += count.ToString();
                count++;
            }

            data.SaveChanges();

            var updatedStudents = data.Students.All();

            foreach (var student in updatedStudents)
            {
                data.Students.Delete(student);
            }

            var selectedStudents =
                data.Students
                .All()
                .Where(st => st.FirstName.Contains("Ivaylo"))
                .Select(st => new
            {
                FirstName = st.FirstName,
                LastName  = st.LastName
            })
                .ToList();

            Console.WriteLine(selectedStudents.Count());

            data.SaveChanges();

            Console.WriteLine(data.Students.All().Count());

            var course = new Course
            {
                Name        = "Pesho's course",
                Description = "The best course in the world"
            };

            data.Courses.Add(course);
            data.SaveChanges();

            var someStudent = new Student
            {
                FirstName   = "Peshlqka",
                LastName    = "Goshlqka",
                Information = new StudentInfo
                {
                    Email = "*****@*****.**"
                },
                StudentNumber = 12345
            };

            data.Students.Add(someStudent);
            data.SaveChanges();

            someStudent.Courses.Add(course);
            var homework = new Homework
            {
                FileUrl  = "pesho.com/pesho.zip",
                Course   = course,
                TimeSent = DateTime.Now
            };

            someStudent.Homeworks.Add(homework);
            data.SaveChanges();

            var studentFromDB = data.Students.All().FirstOrDefault();

            Console.WriteLine(studentFromDB.Homeworks.FirstOrDefault().FileUrl);
        }