static void Main()
        {
            var db = new StudentSystemDbContext();

            Random rand = new Random();

            for (int i = 0; i < 100; i++)
            {
                var student = new Student
                {
                    Age = rand.Next(10, 100),
                    FirstName = "Pesho" + i,
                    LastName = "Goshov" + i,
                    StudentStatus = StudentStatus.Onsite
                };

                student.Courses.Add(new Course
                {
                    Name = "SomeCourse" + i,
                });

                db.Students.Add(student);
            }
            db.SaveChanges();

            var allStudents = db.Students;

            foreach (var item in allStudents)
            {
                Console.WriteLine("{0} - {1} {2}. Status: {3}", item.Id, item.FirstName, item.LastName, item.StudentStatus);
            }
        }
        static void Main()
        {

            var db = new StudentSystemDbContext();

            var student = new Student
            {
                FirstName = "Elena",
                LastName = "Dimirova",
                StudentStatus = StudentStatus.Online,
            };

            db.Students.Add(student);
            db.SaveChanges();
            var course = new Course()
            {
                Name = "Math",
            };

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

            Console.WriteLine(db.Students.First().FirstName);

        }
        static void Main()
        {
            var db = new StudentSystemDbContext();

            var student = new Student() { Name = "Test" };
            db.Students.Add(student);

            var courseEntry = db.Courses.FirstOrDefault();
            courseEntry.Students.Add(student);

            db.SaveChanges();
        }
Ejemplo n.º 4
0
        public static void Main()
        {
            var db = new StudentSystemDbContext();
            using (db)
            {
                var courses = new List<Course> { new Course
                    {
                        Name = "Бази данни 2015",
                        Description = "Ако имате проблеми със създаването на нова база на локалните компютри, моля пуснете скрипта, който ще намерите на тзи линк",
                    }, new Course
                    {
                        Name = "CSS стилизиране (май 2016)",
                        Description = "Практически изпит: 3 юни (групите за изпит ще бъдат обявени допълнително)* \n Поради вътрешно събитие на Telerik, a Progress Company, занятия няма да се провеждат в периода 16 - 19 май 2016 г."
                    }, new Course
                    {
                        Name = "C# за напреднали (май 2016)",
                        Description = "Практически изпит: 3 юни (групите за изпит ще бъдат обявени допълнително)* \n Поради вътрешно събитие на Telerik, a Progress Company, занятия няма да се провеждат в периода 16 - 19 май 2016 г."
                    }
                };

                var numberOfStudents = 30;
                for (int i = 0; i < numberOfStudents; i++)
                {
                    var currentStudent = new Student
                    {
                        Name = ((i*10/1.3+15)/3).ToString(),
                        Number = i + 10000,
                        Age = (int)(i * 1.75)
                    };

                    if (i <= 10)
                    {
                        currentStudent.Gender = Gender.Male;
                        currentStudent.Courses.Add(courses[0]);
                    }
                    else if (i >= 10 && i <= 20)
                    {
                        currentStudent.Gender = Gender.Female;
                        currentStudent.Courses.Add(courses[1]);
                    }
                    else
                    {
                        currentStudent.Gender = Gender.Male;
                        currentStudent.Courses.Add(courses[2]);
                    }

                    db.Students.Add(currentStudent);
                }

                db.SaveChanges();
            }
        }
Ejemplo n.º 5
0
        static void Main(string[] args)
        {
            var db = new StudentSystemDbContext();

            var dbCourse = new Courses
            {
                Name = "DataBases Fundamentals",
                Materials = "Lectures, Videos, Presentations",
                Description = "SQL, EF, JSON, XML",
            };

            var hqc = new Courses
            {
                Name = "High Quality Code",
                Materials = "Lectures, Demos",
                Description = "Design Patterns, Formating, Naming"
            };

            var petko = new Students
            {
                Name = "Petko",
                Number = 20151,
            };
            petko.Courses.Add(dbCourse);

            var mitko = new Students
            {
                Name = "Mitko",
                Number = 20152
            };

            mitko.Courses.Add(hqc);
            mitko.Courses.Add(dbCourse);

            mitko.Homeworks.Add(new Homeworks
            {
                Content = "6 tasks",
                TimeSent = DateTime.Now,
                Courses = hqc
            });

            petko.Homeworks.Add(new Homeworks{
                Courses=dbCourse,
                TimeSent=new DateTime(2013,12,1),
                Content="JSON"
            });

            db.Students.Add(mitko);
            db.Students.Add(petko);
            db.SaveChanges();
        }
Ejemplo n.º 6
0
        public static void Main()
        {
            Database.SetInitializer(new MigrateDatabaseToLatestVersion<StudentSystemDbContext, Configuration>());

            var db = new StudentSystemDbContext();

            Console.WriteLine("Homeworks count before inserting: {0}", db.Homeworks.Count());
            Console.WriteLine("Courses count before inserting: {0}", db.Courses.Count());
            Console.WriteLine("Students count before inserting: {0}", db.Students.Count());

            var student = new Student
            {
                FirstName = "David",
                LastName = "Nielsen",
                Age = 24,
                Number = 31813
            };

            var course = new Course
            {
                Name = "Databases",
                Description = "Introduction to Databases"
            };

            var homework = new Homework
            {
                Content = "Entity Framework Code First Homework",
                TimeSent = DateTime.Now
            };

            course.Homeworks.Add(homework);
            student.Courses.Add(course);
            student.Homeworks.Add(homework);

            db.Homeworks.Add(homework);
            db.Courses.Add(course);
            db.Students.Add(student);
            db.SaveChanges();

            Console.WriteLine(new string('-', 50));
            Console.WriteLine("Homeworks count after inserting: {0}", db.Homeworks.Count());
            Console.WriteLine("Courses count after inserting: {0}", db.Courses.Count());
            Console.WriteLine("Students count after inserting: {0}", db.Students.Count());
        }
Ejemplo n.º 7
0
        public static void Main(string[] args)
        {
            Database.SetInitializer(new MigrateDatabaseToLatestVersion<StudentSystemDbContext, Configuration>());

            var db = new StudentSystemDbContext();

            var student = new Student
            {
                Name = "Pesho",
                Number = 21,
                Email = "*****@*****.**"
            };

            db.Students.Add(student);
            db.SaveChanges();

            var savedStudent = db.Students.First();

            Console.WriteLine(savedStudent.StudentID + "-" + savedStudent.Name);
        }
Ejemplo n.º 8
0
        public static void Main()
        {
            Database.SetInitializer(new MigrateDatabaseToLatestVersion<StudentSystemDbContext, Configuration>());

            var dbContext = new StudentSystemDbContext();

            using (dbContext)
            {
                var student = new Student()
                  {
                      FirstName = "Joe",
                      LastName = "Doe",
                      StudentNumber = "SN1234567"
                  };

                dbContext.Students.Add(student);
                dbContext.SaveChanges();

                var countStudents = dbContext.Students.Count();
                Console.WriteLine(countStudents);
            }
        }
Ejemplo n.º 9
0
        public static void Main()
        {
            var data = new StudentSystemDbContext();

            var course = new Course
            {
                Name = "Code First",
                Description = "Entity Frameset 101"
            };

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

            var count = data.Courses.Count();
            System.Console.WriteLine(count);

            
            foreach (var courseInData in data.Courses)
            {
                System.Console.WriteLine(courseInData.Name);

            }
        }
Ejemplo n.º 10
0
 public static void Main()
 {
     Database.SetInitializer(new MigrateDatabaseToLatestVersion<StudentSystemDbContext, Configuration>());
     var db = new StudentSystemDbContext();
     
 }
        static void Main(string[] args)
        {
            Database.SetInitializer(new DropCreateDatabaseAlways<StudentSystemDbContext>());
            var db = new StudentSystemDbContext();

            var student = new Student
            {
                Age = 23,
                Name = "Svetlin Nakov",
                StudentNumber = "020204"
            };

            var anotherStudent = new Student
            {
                Age = 34,
                Name = "Keno Nakov",
                StudentNumber = "034204"
            };

            db.Students.Add(student);
            db.Students.Add(anotherStudent);
            db.SaveChanges();

            var course = new Course
            {
                Name = "Java",
                Description = "Java for dumies",
                Materials = "Some Books"
            };

            var course2 = new Course
            {
                Name = "JavaScript",
                Description = "Dumies book",
                Materials = "Some Books"
            };

            db.Courses.Add(course);
            db.Courses.Add(course2);
            db.SaveChanges();

            var hw = new Homework
            {
                Content = "Entity Framework",
                TimeSent = new DateTime(2014, 08, 31),
                StudentId = 1,
                CourseId = 2
            };

            var hw2 = new Homework
            {
                Content = "Entity Framework Code First",
                TimeSent = new DateTime(2014, 08, 30),
                StudentId = 2,
                CourseId = 1
            };

            db.Homeworks.Add(hw);
            db.Homeworks.Add(hw2);
            db.SaveChanges();

            var sc = new CourseStudent
            {
                StudentId = 1,
                CourseId = 2
            };

            var sc2 = new CourseStudent
            {
                StudentId = 1,
                CourseId = 1
            };

            var sc3 = new CourseStudent
            {
                StudentId = 2,
                CourseId = 2
            };

            db.CoursesStudents.Add(sc);
            db.CoursesStudents.Add(sc2);
            db.CoursesStudents.Add(sc3);

            anotherStudent.CoursesStudents.Add(new CourseStudent
            {
                CourseId = 1
            });

            db.SaveChanges();

            var savedStudent = db.Students.First();

            Console.WriteLine("ID:" + savedStudent.Id + " Name: " + savedStudent.Name + " StudentNumber: " + savedStudent.StudentNumber  );
        }
Ejemplo n.º 12
0
        static void Main(string[] args)
        {
            StudentSystemDbContext context = new StudentSystemDbContext();

            context.Courses.Any();
        }
 protected BaseApiController()
 {
     var context = new StudentSystemDbContext();
     this.Data = new StudentSystemData(context);
 }
Ejemplo n.º 14
0
        static void Main(string[] args)
        {
            Database.SetInitializer(new MigrateDatabaseToLatestVersion<StudentSystemDbContext, Configuration>());
            //Database.SetInitializer(new DropCreateDatabaseAlways<StudentSystemDbContext>());

            var studentSystemEntities = new StudentSystemDbContext();

            var newCourse = new Course
            {
                Name = "C#2",
                Description = "C# level 2",
                Price = 300.0m,
                StartDate = new DateTime(2014, 05, 13),
                EndDate = new DateTime(2015, 06, 20)
            };

            newCourse.Materials.Add(new Material
            {
                Name = "Demo for second lection of c# 2 course.",
                Link = "https://www.softuni.bg",
                Type = MaterialType.Demo
            });
            newCourse.Materials.Add(new Material
            {
                Name = "Homework for second lection of c# 2 course.",
                Link = "https://www.softuni.bg",
                Type = MaterialType.Homework
            });

            var newStudent = new Student
            {
                FirstName = "Minka",
                LastName = "Svirkova",
                
            };

            newStudent.Homeworks.Add(new Homework
            {
                Content = "Make Rocket.",
                ContentType = ContentType.Zip,
                DeadLine = new DateTime(2014, 05, 22)
            });
            newStudent.Homeworks.Add(new Homework
            {
                Content = "Your task is to create c# program.",
                ContentType = ContentType.Pdf,
                DeadLine = new DateTime(2014, 04, 22),
                
            });
            newCourse.Students.Add(newStudent);

            studentSystemEntities.Courses.Add(newCourse);
            studentSystemEntities.SaveChanges();


            var students = studentSystemEntities.Students;

            foreach (var student in students)
            {
                Console.WriteLine("Student: " + student.FullName);
                Console.Write(" Homeworks:");

                var currStudentHomeworks = student.Homeworks.ToList();

                foreach (var homework in currStudentHomeworks)
                {
                    Console.Write(" " + homework.Content + ", Content Type: " +
                        homework.ContentType.ToString() + ", Deadline: " +
                        homework.DeadLine.ToShortDateString());
                    Console.WriteLine();
                }

                Console.WriteLine();
            }
        }
Ejemplo n.º 15
0
 public StudentController()
 {
     var db = new StudentSystemDbContext();
     this.studentsData = new EfGenericRepository<Student>(db);
 }
Ejemplo n.º 16
0
 public TestController()
 {
     var db = new StudentSystemDbContext();
     this.testsData = new EfGenericRepository<Test>(db);
 }
Ejemplo n.º 17
0
 public HomeworkController()
 {
     var db = new StudentSystemDbContext();
     this.homeworkData = new EfGenericRepository<Homework>(db);
     this.courseData = new EfGenericRepository<Course>(db);
 }