Ejemplo n.º 1
0
        public static void Seed(LectureContext context)
        {
            if (context.User.Any())
            {
                return;
            }

            var users = new User[]
            {
                new User {
                    Username = "******", Email = "*****@*****.**", Password = "******"
                },
                new User {
                    Username = "******", Email = "*****@*****.**", Password = "******"
                },
                new User {
                    Username = "******", Email = "*****@*****.**", Password = "******"
                },
                new User {
                    Username = "******", Email = "*****@*****.**", Password = "******"
                }
            };

            context.User.AddRange(users);
            context.SaveChanges();
        }
Ejemplo n.º 2
0
        public static void Seed(LectureContext context)
        {
            if (context.Uni.Any())
            {
                return;
            }

            var unis = new []
            {
                new Uni
                {
                    Name = "TU Wien"
                },
                new Uni
                {
                    Name = "Uni Wien"
                },
            };

            context.Uni.AddRange(unis);
            context.SaveChanges();
        }
        public static void Seed(LectureContext context)
        {
            if (context.LectureComment.Any())
            {
                return;
            }

            var lectureIds = context.Lecture.Select(x => x.LectureId).ToArray();
            var userIds    = context.User.Select(x => x.UserId).ToArray();

            var lectureComments = new LectureComment[]
            {
                new LectureComment
                {
                    UserId    = userIds[0],
                    LectureId = lectureIds[0],
                    Text      = "Test comment1",
                    Date      = DateTime.Now
                },
                new LectureComment
                {
                    UserId    = userIds[1],
                    LectureId = lectureIds[0],
                    Text      = "Test comment2",
                    Date      = DateTime.Now
                },
                new LectureComment
                {
                    UserId    = userIds[2],
                    LectureId = lectureIds[1],
                    Text      = "Test comment3",
                    Date      = DateTime.Now
                },
            };

            context.LectureComment.AddRange(lectureComments);
            context.SaveChanges();
        }
Ejemplo n.º 4
0
        public static void Seed(LectureContext context)
        {
            if (context.Lecture.Any())
            {
                return;
            }

            var unis = context.Uni.Select(x => x.UniId).ToArray();

            var lectures = new Lecture[]
            {
                new Lecture
                {
                    UniId     = unis[0],
                    Name      = "Infomatik 101",
                    Professor = "Proff Proff",
                    Rating    = 4.6f,
                    Study     = "Informatik",
                    Subject   = "Informations Theorie",
                    Date      = new DateTime()
                },
                new Lecture
                {
                    UniId     = unis[1],
                    Name      = "Algebra 101",
                    Professor = "Proff Soff",
                    Rating    = 3.5f,
                    Study     = "Mathematik",
                    Subject   = "Mathematik",
                    Date      = new DateTime()
                },
            };

            context.Lecture.AddRange(lectures);
            context.SaveChanges();
        }
 public UserController(LectureContext context)
 {
     _context = context;
 }