public ActionResult Create(Student student)
        {
            if (ModelState.IsValid)
            {
                context.Students.Add(student);
                context.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(student);
        }
Exemple #2
0
 public static Student FindOrMake(this DbSet<Student> students, string membershipNumber, string forename, string surname, DbContext ctx)
 {
     var student = students.FirstOrDefault(s => s.MembershipNumber == membershipNumber);
     if (student == null) {
         student = new Student() {
             MembershipNumber = membershipNumber,
             Forename = forename,
             Surname = surname
         };
         students.Add(student);
         ctx.SaveChanges();
     }
     return (student);
 }
Exemple #3
0
 static void ImportStageOne(SceneCRM context, Student student, ChildrenProductionsSpreadsheet.Row row)
 {
     if (row.AttendedStageOne) {
         ImportPlay(context, student, s1, row.StageOneTerm, row.StageOneYear, String.Empty, String.Empty, String.Empty, String.Empty, row.StageOneActor);
     }
 }
Exemple #4
0
 static void ImportReplay(SceneCRM context, Student student, ChildrenProductionsSpreadsheet.Row row)
 {
     if (row.AttendedReplay) {
         ImportPlay(context, student, rp, row.ReplayTerm, row.ReplayYear, row.ReplayProduction, row.ReplayPlay, row.ReplayDramaturg, row.ReplayDirector, row.ReplayActor1,
             row.ReplayActor2, row.ReplayActor3);
     }
 }
Exemple #5
0
        static void ImportPlaymakingOne(SceneCRM context, Student student, ChildrenProductionsSpreadsheet.Row row)
        {
            if (row.AttendedPm1) {
                ImportPlay(context, student, pm1, row.PlaymakingOneTerm, row.PlaymakingOneYear, row.PlaymakingOneProduction, row.PlaymakingOnePlay, row.PlaymakingOneDramaturg, row.PlaymakingOneDirector,
                    row.PlaymakingOneActor1, row.PlaymakingOneActor2, row.PlaymakingOneActor3);

                //var term = context.Terms.FindOrMake(row.PlaymakingOneTerm);
                //var course = context.Courses.FindOrMake(pm1, term, row.PlaymakingOneYear);
                //if (course != null) {
                //    var attendance = new CourseAttendance() {
                //        Student = student,
                //        Course = course,
                //        Completed = true
                //    };
                //    Production production = context.Productions.FindOrMake(row.PlaymakingOneProduction);

                //    if (!String.IsNullOrWhiteSpace(row.PlaymakingOnePlay)) {
                //        var play = new Play() {
                //            Student = student,
                //            Title = row.PlaymakingOnePlay
                //        };
                //        if (production != null) play.Production = production;
                //        attendance.Play = play;
                //        student.Plays.Add(play);
                //        AddPlayVolunteer(context, play, row.PlaymakingOneDramaturg, Jobs.Dramaturg);
                //        AddPlayVolunteer(context, play, row.PlaymakingOneDirector, Jobs.Director);
                //        AddPlayVolunteer(context, play, row.PlaymakingOneActor1, Jobs.Actor);
                //        AddPlayVolunteer(context, play, row.PlaymakingOneActor2, Jobs.Actor);
                //        AddPlayVolunteer(context, play, row.PlaymakingOneActor3, Jobs.Actor);
                //    } else {
                //        AddCourseVolunteer(context, course, row.PlaymakingOneDramaturg, Jobs.Dramaturg);
                //        AddCourseVolunteer(context, course, row.PlaymakingOneActor1, Jobs.Actor);
                //        AddCourseVolunteer(context, course, row.PlaymakingOneActor2, Jobs.Actor);
                //        AddCourseVolunteer(context, course, row.PlaymakingOneActor3, Jobs.Actor);
                //        AddCourseVolunteer(context, course, row.PlaymakingOneDirector, Jobs.Director);
                //    }
                //    student.CourseAttendances.Add(attendance);
            }
        }
Exemple #6
0
 static void ImportPlayback(SceneCRM context, Student student, ChildrenProductionsSpreadsheet.Row row)
 {
     if (row.AttendedPlayback) {
         ImportPlay(context, student, pb, "Playback", row.PlaybackYear, row.PlaybackProduction, row.PlaybackPlay, row.PlaybackDramaturg, row.PlaybackDirector,
                 row.PlaybackActor
                 );
     }
 }
Exemple #7
0
        static object ImportPlay(SceneCRM context, Student student, CourseType courseType, string termName, string termYear, string productionName, string playName,
            string dramaturg, string director, params string[] actors)
        {
            object returnValue = null;
            var term = context.Terms.FindOrMake(termName, context);
            var course = context.Courses.FindOrMake(courseType, term, termYear, context);
            if (course != null) {
                var attendance = new CourseAttendance() {
                    Student = student,
                    Course = course,
                    Completed = true
                };
                Production production = context.Productions.FindOrMake(productionName, context);

                if (!String.IsNullOrWhiteSpace(playName)) {
                    var play = new Play() {
                        Student = student,
                        Title = playName
                    };
                    if (production != null) play.Production = production;
                    attendance.Play = play;
                    student.Plays.Add(play);
                    AddPlayVolunteer(context, play, dramaturg, Jobs.Dramaturg);
                    AddPlayVolunteer(context, play, director, Jobs.Director);
                    foreach (var actor in actors) {
                        AddPlayVolunteer(context, play, actor, Jobs.Actor);
                    }
                    returnValue = play;
                } else {
                    AddCourseVolunteer(context, course, dramaturg, Jobs.Dramaturg);
                    AddCourseVolunteer(context, course, director, Jobs.Director);
                    foreach (var actor in actors) {
                        AddCourseVolunteer(context, course, actor, Jobs.Actor);
                    }
                    returnValue = course;
                }
                student.CourseAttendances.Add(attendance);
            }
            return(returnValue);
        }
Exemple #8
0
 static void ImportOneOnOne(SceneCRM context, Student student, ChildrenProductionsSpreadsheet.Row row)
 {
     if (row.AttendedOneOnOne) {
         ImportPlay(context, student, oneOnOne, row.OneonOneTerm, row.OneonOneYear, row.OneonOneProduction, row.OneonOnePlay, row.OneonOneWriter, row.OneonOneDirector, row.OneonOneActor);
     }
 }
 public ActionResult Edit(Student student)
 {
     if (ModelState.IsValid)
     {
         context.Entry(student).State = EntityState.Modified;
         context.SaveChanges();
         return RedirectToAction("Index");
     }
     return View(student);
 }