コード例 #1
0
        public override Teacher Save(Teacher teacher)
        {
            try
            {
                using (TransactionScope transaction = new TransactionScope())
                {
                    ModifyTeacher(teacher);
                    //ModifyPerson(teacher.Person);
                    _personEditorService.Modify(teacher.Person);
                    ModifyReferee(teacher.Referee);
                    DeleteOLevelResult(teacher);

                    _da.Delete <TEACHER_EDUCATIONAL_QUALIFICATION>(p => p.Person_Id == teacher.Person.Id);
                    _da.Delete <TEACHER_EMPLOYMENT_HISTORY>(p => p.Person_Id == teacher.Person.Id);
                    _da.Delete <TEACHER_STUDENT_CATEGORY>(p => p.Person_Id == teacher.Person.Id);
                    _da.Delete <TEACHER_AVAILABILITY>(p => p.Person_Id == teacher.Person.Id);
                    _da.Delete <TEACHER_AWARD>(p => p.Person_Id == teacher.Person.Id);

                    _da.Create(teacher.StudentCategories);
                    _da.Create(teacher.TeacherAvailabilities);
                    _da.Create(teacher.EducationalQualifications);

                    if (teacher.EmploymentHistories != null && teacher.EmploymentHistories.Count > 0)
                    {
                        _da.Create(teacher.EmploymentHistories);
                    }
                    if (teacher.TeacherAwards != null && teacher.TeacherAwards.Count > 0)
                    {
                        _da.Create(teacher.TeacherAwards);
                    }

                    string passportFilePath = SaveHelper(teacher);
                    teacher.ImageFileUrl = passportFilePath;
                    teacher.PaymentSlip  = _paymentService.GetPaymentSlipBy(teacher.Person);

                    transaction.Complete();
                }

                return(teacher);
            }
            catch (Exception)
            {
                throw;
            }
        }
コード例 #2
0
        public override Employer Save(Employer employer)
        {
            try
            {
                using (TransactionScope transaction = new TransactionScope())
                {
                    ModifyEmployer(employer);
                    _personEditorService.Modify(employer.Person);
                    DeleteStudentCategory(employer);

                    bool saved = base.SaveStudentCategory(employer.StudentCategories);
                    if (saved == false)
                    {
                        throw new Exception("Student Category save operation failed!");
                    }

                    employer.PaymentSlip = _paymentService.GetPaymentSlipBy(employer.Person);


                    //ServiceCharge serviceCharge = null;
                    //List<Payment> payments = _da.GetModelsBy<Payment, PAYMENT>(p => p.Person_Id == employer.Person.Id && p.Service_Charge_Id == serviceCharge.Id);
                    //if (payments != null || payments.Count > 0)
                    //{
                    //    employer.PaymentSlip = new PaymentSlip();
                    //    employer.PaymentSlip.Payment = payments[0];
                    //}


                    transaction.Complete();
                }

                return(employer);
            }
            catch (Exception)
            {
                throw;
            }
        }