Exemplo n.º 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();
            }
        }
Exemplo n.º 2
0
        static void Main()
        {
            Database.SetInitializer(new MigrateDatabaseToLatestVersion<StudentSystemDBContext, Configuration>());

            var db = new StudentSystemDBContext();

            var studentsWithSubmissions = from h in db.Homeworks
                                          from s in db.Students
                                          where s.Id == h.SubmissionStudent.Id
                                          select s.Name + " " + h.Content;
            foreach (var item in studentsWithSubmissions.ToList())
            {
                Console.WriteLine(item.ToString());
            }

            db.Courses.ToList().ForEach(c => c.Resources.ToList().ForEach(r => Console.WriteLine(c.Name + " " + r.Name)));

            Course courseOne = new Course()
            {
                Name = "Guga Buga Course",
                StartDate = new DateTime(2222, 3, 1),
                Price = 354
            };

            Resource resourceVideo = new Resource()
            {
                Name = "Video resource",
                TypeOfResource = ResourceType.Video,
                Link = "The Link"
            };
            Resource resourceDocs = new Resource()
            {
                Name = "Docs resource",
                TypeOfResource = ResourceType.Document,
                Link = "The Link"
            };
            Resource resourceOther = new Resource()
            {
                Name = "Other resource",
                TypeOfResource = ResourceType.Other,
                Link = "The Link"
            };
            courseOne.Resources.Add(resourceDocs);
            courseOne.Resources.Add(resourceOther);
            courseOne.Resources.Add(resourceVideo);

            Student student = new Student()
            {
                Name = "Gargandiua",
                BirthDay = new DateTime(1835, 1, 1),
                RegistrationDate = new DateTime(2020, 3, 3)
            };
            student.Courses.Add(courseOne);

            Resource resourceNew = new Resource()
            {
                Name = "The New RECOURCE",
                Link = "The New Link",
                TypeOfResource = ResourceType.Presentation
            };

            db.Courses.Add(courseOne);
            db.Students.Add(student);
            db.Resources.Add(resourceDocs);
            db.Resources.Add(resourceNew);
            db.Resources.Add(resourceOther);
            db.Resources.Add(resourceVideo);
            db.SaveChanges();
        }