Esempio n. 1
0
 public void AddSubjects(List <ISubject> subjects)
 {
     if (subjects == null)
     {
         throw new ArgumentNullException(nameof(subjects));
     }
     Subjects.AddRange(subjects);
 }
Esempio n. 2
0
        /// <summary>
        /// Legt die Fächer und Musteranmeldungen an, falls noch keine Datenbank existiert.
        /// Die Token 1-4 (3AHIF1...3AHIF4) haben eine Anmeldung, 5 - 10 nicht.
        /// </summary>
        public void Seed()
        {
            Randomizer.Seed = new Random(1015);
            Faker f = new Faker();

            TeacherTokens.Add(new TeacherToken {
                TeacherTokenId = Guid.NewGuid().ToString("n")
            });
            SaveChanges();

            var subjects = new List <Subject>
            {
                new Subject {
                    SubjectId = "BAP", Name = "Business Applications", Order = 1
                },
                new Subject {
                    SubjectId = "GAD", Name = "Game Development", Order = 2
                },
                new Subject {
                    SubjectId = "IOT", Name = "Internet of Things", Order = 3
                },
                new Subject {
                    SubjectId = "OPS", Name = "Operations and Services", Order = 4
                }
            };

            Subjects.AddRange(subjects);
            SaveChanges();

            foreach (var sc in new string[] { "3AHIF", "3BHIF", "3CHIF", "3EHIF" })
            {
                foreach (var nr in Enumerable.Range(1, 10))
                {
                    Token token = new Token
                    {
                        SchoolClass = sc,
                        TokenId     = sc + nr.ToString(),
                    };

                    token.Registrations = new List <Registration>();
                    if (nr < 5)
                    {
                        int i = 1;
                        foreach (var s in f.Random.Shuffle(subjects))
                        {
                            token.Registrations.Add(new Registration {
                                Subject = s, Rating = i++
                            });
                        }
                        token.LastValidRegistration = new DateTime(2020, 5, 1).AddSeconds(f.Random.Int(0, 20 * 86400));
                    }
                    Tokens.Add(token);
                }
            }
            SaveChanges();
        }
Esempio n. 3
0
 private void AddSubjects(IEnumerable <string> newSubjects)
 {
     Subjects.AddRange(
         from newSubject in newSubjects
         where Subjects.All(ss => ss.Subject != newSubject)
         select new SetSubject {
         Set     = this,
         Subject = newSubject,
         SetID   = ID
     });
 }
 public void AddSubjects(List <string> subjects)
 {
     Subjects.AddRange(subjects);
     Weight = CalcWeight();
 }