protected void btnAddMember_Click(object sender, EventArgs e) { //Create the new department member DepartmentMember member = new DepartmentMember(); member.DepartmentFIS = STR_FRAC; member.FirstName = txtFName.Text; member.LastName = txtLName.Text; member.OtherDepartmentName = string.IsNullOrEmpty(txtDepartment.Text) ? "Other" : txtDepartment.Text; member.LoginID = txtLoginID.Text.ToLower().Trim(); //Create the membership object CommitteeMember committeeAccess = new CommitteeMember(); committeeAccess.AssociatedPosition = currentPosition; committeeAccess.DepartmentMember = member; switch (dlistMemberType.SelectedValue) { case "Committee": committeeAccess.MemberType = MemberTypeBLL.GetByID((int)MemberTypes.CommitteeMember); break; case "Faculty": committeeAccess.MemberType = MemberTypeBLL.GetByID((int)MemberTypes.FacultyMember); break; case "Review": committeeAccess.MemberType = MemberTypeBLL.GetByID((int)MemberTypes.Reviewer); break; } //save the department member and add to the position committee for this position using (var ts = new TransactionScope()) { DepartmentMemberBLL.EnsurePersistent(member); committeeAccess.DepartmentMember = member; currentPosition.CommitteeMembers.Add(committeeAccess); Position position = currentPosition; PositionBLL.EnsurePersistent(position); ts.CommitTransaction(); } //Display an update successful message lblCommitteeUpdated.Text = "Committee Membership Successfully Updated"; //rebind the datagrid this.bindMembers(); this.ShowUpdateAcessRegion(); }
public static void UpdateAccess(DepartmentMember member, Position position, bool committee, bool faculty, bool reviewer) { //Now get all committee roles for this member List <CommitteeMember> memberAccess = CommitteeMemberBLL.GetByAssociationsPosition(position, member); CommitteeMember currentMember = new CommitteeMember(); currentMember.DepartmentMember = member; currentMember.AssociatedPosition = position; //First check for Committee Member access CommitteeMember currentMemberAccess = DepartmentMemberBLL.MemberInCommitteeListOfType(memberAccess, MemberTypes.CommitteeMember); if (currentMemberAccess == null) { //member is not in the committee list. If the box is checked, add them to the committee list if (committee) { CommitteeMember newMemberAccess = new CommitteeMember(); newMemberAccess.DepartmentMember = member; newMemberAccess.AssociatedPosition = position; newMemberAccess.MemberType = MemberTypeBLL.GetByID((int)MemberTypes.CommitteeMember); position.CommitteeMembers.Add(newMemberAccess); } } else { //member is in the committee list. Remove if the box is unchecked if (!committee) { position.CommitteeMembers.Remove(currentMemberAccess); } } //Now check for Faculty Member access currentMemberAccess = DepartmentMemberBLL.MemberInCommitteeListOfType(memberAccess, MemberTypes.FacultyMember); if (currentMemberAccess == null) { //member is not in the faculty list. If the box is checked, add them if (faculty) { CommitteeMember newMemberAccess = new CommitteeMember(); newMemberAccess.DepartmentMember = member; newMemberAccess.AssociatedPosition = position; newMemberAccess.MemberType = MemberTypeBLL.GetByID((int)MemberTypes.FacultyMember); position.CommitteeMembers.Add(newMemberAccess); } } else { //member is in the committee list. Remove if the box is unchecked if (!faculty) { position.CommitteeMembers.Remove(currentMemberAccess); } } //Finally check for review member access currentMemberAccess = DepartmentMemberBLL.MemberInCommitteeListOfType(memberAccess, MemberTypes.Reviewer); if (currentMemberAccess == null) { //member is not in the reviewer list. If the box is checked, add them if (reviewer) { CommitteeMember newMemberAccess = new CommitteeMember(); newMemberAccess.DepartmentMember = member; newMemberAccess.AssociatedPosition = position; newMemberAccess.MemberType = MemberTypeBLL.GetByID((int)MemberTypes.Reviewer); position.CommitteeMembers.Add(newMemberAccess); } } else { //member is in the committee list. Remove if the box is unchecked if (!reviewer) { position.CommitteeMembers.Remove(currentMemberAccess); } } //Position position = position; PositionBLL.EnsurePersistent(position); }