private void InitializeDbData()
        {
            List <ActivityType> activityTypes = new List <ActivityType>
            {
                new ActivityType
                {
                    Name = "Course"
                },
                new ActivityType
                {
                    Name = "Laboratory"
                },
                new ActivityType
                {
                    Name = "Seminary"
                }
            };

            foreach (var activityType in activityTypes)
            {
                if (activitiesRepository.GetActivityType(activityType.Name) == null)
                {
                    dataContext.ActitivityTypes.Add(activityType);
                }
            }

            #region dummyData

            /*List<ActivityOccurence> activityOccurences = new List<ActivityOccurence>
             * {
             *  new ActivityOccurence
             *  {
             *      OccurenceDate = DateTime.Now
             *  },
             *  new ActivityOccurence
             *  {
             *      OccurenceDate = DateTime.Now.AddDays(-1).AddHours(-5).AddMinutes(-1)
             *  }
             * };
             * List<Activity> activities = new List<Activity> {
             *  new Activity
             *  {
             *      Name = "OOP",
             *      ActivityType = activityTypes[0],
             *      Description = "Lorem ipsum dolor sit amet, duo ei volutpat voluptaria, his ne vero suscipiantur. Mel sapientem interesset complectitur in",
             *      OccurenceDates = new List<ActivityOccurence>
             *      {
             *          activityOccurences[0],
             *          activityOccurences[1]
             *      }
             *  },
             *  new Activity
             *  {
             *      Name = "AI",
             *      ActivityType = activityTypes[1],
             *      Description = "His ne vero suscipiantur. Mel sapientem interesset complectitur in",
             *      OccurenceDates = new List<ActivityOccurence>
             *      {
             *          activityOccurences[1]
             *      }
             *  }
             * };
             * List<Student> students = new List<Student>
             * {
             *  new Student
             *  {
             *      FirstName = "Mark",
             *      LastName = "Zuckerberg",
             *      Email = "*****@*****.**",
             *      //Activities = new List<Activity> { activities[0] },
             *      ActivitiesLink = new List<StudentActivity>
             *      {
             *          new StudentActivity
             *          {
             *              Activity = activities[0]
             *          }
             *      },
             *      ActivityInfos = new List<ActivityInfo>
             *      {
             *          new ActivityInfo
             *          {
             *              Grade = 6,
             *              Presence = true,
             *              Activity = activities[0],
             *              OccurenceDate = activityOccurences[0]
             *          }
             *      }
             *  },
             *  new Student
             *      {
             *      FirstName = "Bill",
             *      LastName = "Gates",
             *      Email = "*****@*****.**",
             *      //Activities = new List<Activity> { activities[1] },
             *      ActivitiesLink = new List<StudentActivity>
             *      {
             *          new StudentActivity
             *          {
             *              Activity = activities[1]
             *          }
             *      },
             *      ActivityInfos = new List<ActivityInfo>
             *      {
             *          new ActivityInfo
             *          {
             *              Grade = 0,
             *              Presence = false,
             *              Activity = activities[1],
             *              OccurenceDate = activityOccurences[1]
             *          }
             *      }
             *  },
             *  new Student
             *  {
             *      FirstName = "Dennis",
             *      LastName = "Richie",
             *      Email = "*****@*****.**",
             *      //Activities = new List<Activity> { activities[0] },
             *      ActivitiesLink = new List<StudentActivity>
             *      {
             *          new StudentActivity
             *          {
             *              Activity = activities[0]
             *          }
             *      },
             *      ActivityInfos = new List<ActivityInfo>
             *      {
             *          new ActivityInfo
             *          {
             *              Grade = 10,
             *              Presence = true,
             *              Activity = activities[0],
             *              OccurenceDate = activityOccurences[0]
             *          }
             *      }
             *  },
             *  new Student
             *  {
             *      FirstName = "Linus",
             *      LastName = "Torvalds",
             *      Email = "*****@*****.**",
             *      //Activities = new List<Activity> { activities[0], activities[1] },
             *      ActivitiesLink = new List<StudentActivity>
             *      {
             *          new StudentActivity
             *          {
             *              Activity = activities[0]
             *          },
             *          new StudentActivity
             *          {
             *              Activity = activities[1]
             *          }
             *      },
             *      ActivityInfos = new List<ActivityInfo>
             *      {
             *          new ActivityInfo
             *          {
             *              Grade = 10,
             *              Presence = true,
             *              Activity = activities[0],
             *              OccurenceDate = activityOccurences[0]
             *          },
             *          new ActivityInfo
             *          {
             *              Grade = 7,
             *              Presence = true,
             *              Activity = activities[1],
             *              OccurenceDate = activityOccurences[1]
             *          },
             *          new ActivityInfo
             *          {
             *              Grade = 8,
             *              Presence = true,
             *              Activity = activities[0],
             *              OccurenceDate = activityOccurences[1]
             *          }
             *      }
             *  }
             * };
             * List<Professor> professors = new List<Professor>
             * {
             *  new Professor
             *  {
             *      FirstName = "John",
             *      LastName = "Doe",
             *      Email = "*****@*****.**",
             *      Activities = activities
             *  }
             * };
             *
             * activityTypes.ForEach(act =>
             * {
             *  if (activitiesRepository.GetActivityType(act.Name) == null)
             *  {
             *      dataContext.ActitivityTypes.Add(act);
             *  }
             * });
             * professors.ForEach(prof => dataContext.Professors.Add(prof));
             * students.ForEach(stud => dataContext.Students.Add(stud));*/
            #endregion

            dataContext.SaveChanges();
        }
示例#2
0
 public void Save()
 {
     dataContext.SaveChanges();
 }