public Examination Add(Examination exam) { exam.Id = 0; exam.Status = (int)ExaminationEnums.STATUS_ACTIVE; var rs = repository.Insert(exam); // add transcript TranscriptService transcriptService = new TranscriptService(); transcriptService.AddExamToTranscript(rs); return(rs); }
public IEnumerable <ClassSubject> AddSubjectToClass(int classId, List <ClassSubjectModel> subjectIds) { var origin = repository.Get(classId); var rs = new List <ClassSubject>(); //add subject to class subjectIds.ForEach(i => { var found = origin.ClassSubjects.Where(cs => cs.SubjectId == i.SubjectId).FirstOrDefault(); if (found == null) { var classSubject = new ClassSubject { Id = 0, Status = (int)ClassSubjectEnums.STATUS_ACTIVE, ClassId = classId, SubjectId = i.SubjectId, Teacher = i.TeacherId }; origin.ClassSubjects.Add(classSubject); rs.Add(classSubject); } else { if (found.Status == (int)ClassSubjectEnums.STATUS_DISABLE) { rs.Add(found); } found.Status = (int)ClassSubjectEnums.STATUS_ACTIVE; found.Teacher = i.TeacherId; } }); repository.Update(origin); //update transcript of class var subjectRepository = new SubjectRepository(); rs.ForEach(cs => { cs.Subject = subjectRepository.Get(cs.SubjectId); }); var transcriptService = new TranscriptService(); transcriptService.AddSubjectToClassTranscript(classId, rs); return(rs); }
public IEnumerable <ClassSubject> RemoveSubjectFromClass(int classId, List <ClassSubjectModel> subjectIds) { var rs = new List <ClassSubject>(); var origin = repository.Get(classId); //remove subject subjectIds.ForEach(i => { var found = origin.ClassSubjects.Where(cs => cs.SubjectId == i.SubjectId).FirstOrDefault(); if (found != null && found.Status != (int)ClassSubjectEnums.STATUS_DISABLE) { found.Status = (int)ClassSubjectEnums.STATUS_DISABLE; found.Teacher = null; rs.Add(found); } }); repository.Update(origin); //remove transcript of deleted subjects var transcriptService = new TranscriptService(); transcriptService.DeleteSubjectFromTranscript(classId, rs); return(rs); }
public IEnumerable <ClassMember> RemoveStudentFromClass(int classId, List <int> studentIds) { var rs = new List <ClassMember>(); var origin = repository.Get(classId); var removedStudentIds = new List <int>(); studentIds.ForEach(i => { var found = origin.ClassMembers.Where(cm => cm.StudentId == i).FirstOrDefault(); if (found != null && found.Status != (int)ClassMemberEnums.STATUS_DISABLE) { found.Status = (int)ClassMemberEnums.STATUS_DISABLE; rs.Add(found); removedStudentIds.Add(i); } }); repository.Update(origin); //remove transcript of student var transcriptService = new TranscriptService(); transcriptService.DeleteMultipleTranscript(removedStudentIds, classId); return(rs); }
public IEnumerable <ClassMember> AddStudentToClass(int classId, List <int> studentIds) { var origin = repository.Get(classId); var rs = new List <ClassMember>(); var newStudentIds = new List <int>(); //create new class member studentIds.ForEach(i => { var found = origin.ClassMembers.Where(cm => cm.StudentId == i).FirstOrDefault(); if (found == null) { var classMember = new ClassMember { Id = 0, Status = (int)ClassMemberEnums.STATUS_ACTIVE, ClassId = classId, StudentId = i }; origin.ClassMembers.Add(classMember); rs.Add(classMember); newStudentIds.Add(i); } else if (found.Status == (int)ClassMemberEnums.STATUS_DISABLE) { found.Status = (int)ClassMemberEnums.STATUS_ACTIVE; rs.Add(found); newStudentIds.Add(i); } }); repository.Update(origin); //create new transcript var transcriptService = new TranscriptService(); transcriptService.AddMultipleTranscript(newStudentIds, classId); return(rs); }