コード例 #1
0
ファイル: EmployeeBL.cs プロジェクト: EasyExpress/Easylink
        public void InsertEmployee(Employee employee)
        {
            employee.ValidateRules();

            Action procedure = () =>
                {

                    if (employee.Address !=null && !string.IsNullOrEmpty(employee.Address.HouseNumber))
                    {
                        Database.Insert(employee.Address);
                    }

                    if (employee.AdditionalInfo!= null && !string.IsNullOrEmpty(employee.AdditionalInfo.Notes))
                    {
                        Database.Insert(employee.AdditionalInfo);
                    }
 
                    Database.Insert(employee);

                    employee.Programs.ForEach(p =>
                        {
                            p.EmployeeId = employee.Id;

                            Database.Insert(p);
                        });
                };

            Database.ExecuteInTransaction(procedure);
        }
コード例 #2
0
ファイル: EmployeeBL.cs プロジェクト: EasyExpress/Easylink
        public void UpdateEmployee(Employee employee)
        {
            employee.ValidateRules();

            Action procedure = () =>
                {

                    Database.Save(employee.Address);

                    Database.Save(employee.FinancialInfo);

                    Database.Save(employee.AdditionalInfo);

                    Database.Update(employee);

                    employee.Programs.ForEach(p =>
                        {
                            p.EmployeeId = employee.Id;

                            Database.Save(p);
                        });
                };

            Database.ExecuteInTransaction(procedure);
        }