public TrainingClassSummaryItem(Models.DB.TrainingClass dataEntity) { this.TrainingClassID = dataEntity.TrainingClassId; this.TrainingDate = dataEntity.TrainingDate; this.TrainingTitle = dataEntity.Training.TrainingTitle; this.TrainingID = dataEntity.TrainingId; buildStudents(dataEntity); buildInstructors(dataEntity); }
private void buildInstructors(Models.DB.TrainingClass dataEntity) { List <Training.TrainingClassInstructorSummaryItem> instructors = new List <Training.TrainingClassInstructorSummaryItem>(); foreach (var item in dataEntity.TrainingClassInstructor) { instructors.Add(new Training.TrainingClassInstructorSummaryItem(item)); } this.Instructors = instructors.OrderBy(i => i.MemberName).ToList(); }
private void buildStudents(Models.DB.TrainingClass dataEntity) { List <Training.TrainingClassStudentSummaryItem> students = new List <Training.TrainingClassStudentSummaryItem>(); foreach (var item in dataEntity.TrainingClassStudent) { students.Add(new Training.TrainingClassStudentSummaryItem(item)); } this.Students = students.OrderBy(s => s.MemberName).ToList(); }
public ActionResult CreateTrainingClass(Models.Training.TrainingClassInsert model) { Models.DB.TrainingClass dbTrainingClass = new Models.DB.TrainingClass(); Int32 trainingClassId; dbTrainingClass.TrainingId = model.TrainingID; dbTrainingClass.TrainingDate = model.TrainingDate; dbTrainingClass.TrainingClassStudent = new List <TrainingClassStudent>(); dbTrainingClass.TrainingClassInstructor = new List <TrainingClassInstructor>(); dbTrainingClass.Created = DateTime.UtcNow; try { _context.TrainingClass.Add(dbTrainingClass); _context.SaveChanges(); trainingClassId = dbTrainingClass.TrainingClassId; } catch (Exception exc) { throw exc; } return(RedirectToAction("EditTrainingClass", new { id = trainingClassId })); }