public void insertDumyData(int annualCourseId)
        {
            Random r = new Random();
            int range = r.Next(50, 100);

            for (int i = 0; i < range; i++)
            {
                int mark = r.Next(0, 100);
                Student s = new Student
                {
                    AnnualCourseId = annualCourseId,
                    Name = "Nguyen Van a " + i,
                    Mark = mark
                };
                db.Students.Add(s);
                db.SaveChanges();
            }
        }
Ejemplo n.º 2
0
        public ActionResult insertDumyData(int annualCourseId)
        {
            Random r = new Random();
            int range = r.Next(50, 100);

            for (int i = 0; i < range; i++)
            {
                int mark = r.Next(0, 100);
                Student s = new Student
                {
                    AnnualCourseId = annualCourseId,
                    Name = "Nguyen Van a " + i,
                    Mark = mark
                };
                db.Students.Add(s);
                db.SaveChanges();
            }
            ViewBag.annualCourses = new SelectList(db.AnnualCourses, "annualCourseId", "annualCourseId");
            return View();
        }