Example #1
0
        public static int Update(Branch branch)
        {
            int rowsAffected = 0;

            try
            {
                using (TransactionScope scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled))
                {
                    if (branch.ActivityHours != null)
                    {
                        foreach (var ActivityHours in branch.ActivityHours)
                        {
                            ActivityHours.Branch = new Branch {
                                Id = branch.Id
                            };
                            BranchActivityHoursDataManager.UpdateBranchActivityHours(ActivityHours);
                        }
                    }
                    if (branch.ExamRules != null)
                    {
                        branch.ExamRules.Branch = new Branch {
                            Id = branch.Id
                        };
                        BranchRulesDataManager.UpdateExamRules(branch.ExamRules);
                    }
                    if (branch.AttendanceRules != null)
                    {
                        branch.AttendanceRules.Branch = new Branch {
                            Id = branch.Id
                        };
                        BranchRulesDataManager.UpdateAttendanceRules(branch.AttendanceRules);
                    }
                    if (branch.Address != null)
                    {
                        AddressManager.UpdateAddress(branch.Address);
                    }
                    rowsAffected = BranchDataManager.UpdateBranch(branch);
                    scope.Complete();
                    return(rowsAffected);
                }
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Example #2
0
        public static int Insert(Branch branch)
        {
            int rowsAffected = 0;

            try
            {
                using (TransactionScope scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled))
                {
                    if (branch.Address != null)
                    {
                        branch.Address.Id = AddressManager.InsertAddress(branch.Address);
                    }
                    rowsAffected = BranchDataManager.InsertBranch(branch);
                    if (branch.ActivityHours != null)
                    {
                        foreach (var activityHours in branch.ActivityHours)
                        {
                            activityHours.Branch.Id = rowsAffected;
                            BranchActivityHoursDataManager.InsertBranchActivityHours(activityHours);
                        }
                    }
                    //if (branch.ExamRules != null)
                    //{
                    //    branch.ExamRules.Branch.Id = rowsAffected;
                    //    BranchRulesDataManager.InsertExamRules(branch.ExamRules);
                    //}
                    //if (branch.AttendanceRules != null)
                    //{
                    //    branch.AttendanceRules.Branch.Id = rowsAffected;
                    //    BranchRulesDataManager.InsertAttendanceRules(branch.AttendanceRules);
                    //}
                    scope.Complete();
                    return(rowsAffected);
                }
            }
            catch (Exception ex)
            {
                throw;
            }
        }