public bool CheckFilterOnMember(Member member) { bool? memberResult = null; //loop filters foreach (IMemberFilter filter in GetAllFilters()) { bool result = filter.CheckFilterOnMember(member); if (result == true && m_conditionalOperator == MemberFiltersConditionalOperator.OR) { memberResult = true; } else if (result == false && m_conditionalOperator == MemberFiltersConditionalOperator.AND) { memberResult = false; } if (memberResult != null) { break; } } //if AND operator and no failure, set success if (m_conditionalOperator == MemberFiltersConditionalOperator.AND && memberResult != false) { memberResult = true; } return (memberResult == true); }
public bool CheckFilterOnMember(Member a_member) { List<string> valuesToCheck = new List<string>(); switch (m_field) { case MemberFilterField.Name: valuesToCheck.Add(a_member.Name); break; case MemberFilterField.PersonalNumber: valuesToCheck.Add(a_member.PersonalNumber); break; case MemberFilterField.UniqueId: valuesToCheck.Add(a_member.UniqueId); break; case MemberFilterField.BoatOfType: foreach (Boat boat in a_member.Boats) { valuesToCheck.Add(boat.TypeAsString); } break; } foreach (string value in valuesToCheck) { if (CheckValue(value, m_searchValue)) { return true; } } return false; }
public bool AddMember(Member a_member, bool generateUniqueId = false) { //check if to generate unique id for the member if (generateUniqueId) { a_member.SetUniqueId(this.generateUniqueMemberId()); } if (a_member.HasCorrectDetails) { //subscribe to member events a_member.AddSubscriber(this); //add it to array m_members.Add(a_member); //notify subscribers this.NotifySubscribersChangeMade(a_member); return true; } return false; }
private void NotifySubscribersChangeMade(Member a_member) { if (m_observers != null) { foreach (MemberObserver o in m_observers) { o.MemberChangeMade(a_member); } } }
private bool DeleteMember(Member a_member) { bool success = this.Members.Remove(a_member); if (success) { //un-subscribe to member events a_member.RemoveSubscriber(this); this.NotifySubscribersChangeMade(a_member); } return success; }
/// <summary> /// Checks if supplied personal number is unique in the members list /// </summary> /// <param name="personalNumber"></param> /// <param name="memberToExclude">if to exclude a member (like when editing a member this member should not be checked against itself)</param> /// <returns></returns> public bool IsPersonalNumberUnique(string personalNumber, Member memberToExclude = null) { foreach (Model.Member member in m_members) { //if not to exclude this member if (memberToExclude == null || String.IsNullOrWhiteSpace(memberToExclude.UniqueId) || memberToExclude.UniqueId != member.UniqueId) { if (member.PersonalNumber == personalNumber) { //not unique return false; } } } return true; }