Пример #1
0
        public override Employer Save(Employer employer)
        {
            try
            {
                PaymentSlip slip        = null;
                Employer    newEmployer = null;

                using (TransactionScope transaction = new TransactionScope())
                {
                    byte[] passwordHash = _gateService.CreatePasswordHash(employer.LoginDetail.RawPassword);
                    employer.LoginDetail.Password = passwordHash;

                    newEmployer = _da.Create(employer);
                    if (newEmployer == null || newEmployer.Person.Id <= 0)
                    {
                        throw new Exception("Employer registration failed! " + TRY_AGAIN);
                    }

                    employer.Person.Id = newEmployer.Person.Id;
                    foreach (EmployerStudentCategory employerStudentCategory in employer.StudentCategories)
                    {
                        employerStudentCategory.Person = employer.Person;
                    }

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


                    employer.Payments[0].ServiceCharge = _serviceCharge.GetChargesBy(employer.Person.Type);
                    employer.Payments[0].Person        = employer.Person;
                    slip = _paymentService.Pay(employer.Payments[0]);
                    if (slip == null || slip.Payment == null || slip.Payment.Id <= 0)
                    {
                        throw new Exception("Payment entry creation failed!");
                    }

                    newEmployer.PaymentSlip = slip;
                    transaction.Complete();
                }

                return(newEmployer);
            }
            catch (Exception)
            {
                throw;
            }
        }
Пример #2
0
        public override Teacher Save(Teacher teacher)
        {
            try
            {
                PaymentSlip slip       = null;
                Teacher     newTeacher = null;

                using (TransactionScope transaction = new TransactionScope())
                {
                    byte[] passwordHash = _gateService.CreatePasswordHash(teacher.LoginDetail.RawPassword);
                    teacher.LoginDetail.Password = passwordHash;

                    newTeacher = _da.Create(teacher);
                    if (newTeacher == null || newTeacher.Person.Id <= 0)
                    {
                        throw new Exception("Teacher subscription operation failed! " + TRY_AGAIN);
                    }

                    teacher.Person.Id = newTeacher.Person.Id;
                    string passportFilePath = SaveHelper(teacher);
                    newTeacher.ImageFileUrl = passportFilePath;


                    teacher.Payments[0].Person        = teacher.Person;
                    teacher.Payments[0].ServiceCharge = _serviceCharge.GetChargesBy(teacher.Person.Type);

                    slip = _paymentService.Pay(teacher.Payments[0]);
                    if (slip == null || slip.Payment == null || slip.Payment.Id <= 0)
                    {
                        throw new Exception("Payment entry creation failed!");
                    }

                    newTeacher.PaymentSlip = slip;
                    transaction.Complete();
                }

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