/// <summary> /// Method that receives message and model /// </summary> /// <param name="msg"></param> private void ReceivedMessageMember(MessageMemberModel msg) { if (msg.Selection == "ListSelect") { Membership = new MembershipModel(msg.Membership); } }
/// <summary> /// Method that receives messenger calls to do embedded functions /// </summary> /// <param name="member"></param> private void ReceiveMembership(MessageMemberModel member) { // For updating membership if (member.Selection == "Update") { if (!Memberships.Contains(member.Membership)) { // Using indexer. Memberships[Memberships.IndexOf(SelectedMember)] = member.Membership; } else if (!SelectedMember.Equals(member.Membership)) { // Notify user about duplicate membership Messenger.Default.Send <NotificationMessage>(new NotificationMessage($"{MemberAlreadyExistMsg}\n" + $"{MergingMembershipsMsg}")); // Removing outdated data using minus operator. Memberships -= SelectedMember; } } // For adding membership else if (member.Selection == "Add") { // Checks if membership is already in list. if (Memberships.Contains(member.Membership)) { // Notifies user that it exists then returns. Messenger.Default.Send <NotificationMessage>(new NotificationMessage(MemberAlreadyExistMsg)); return; } // Membership not found then add using add operator. Memberships += member.Membership; } // For deleting membership else if (member.Selection == "Delete") { // Confirms that membership is in list if (Memberships.Contains(member.Membership)) { // Removes found membership. Memberships.Remove(SelectedMember); Messenger.Default.Send(new NotificationMessage(DeleteMsg)); } } else if (member.Selection == "ListSelect") { return; } else { Messenger.Default.Send <NotificationMessage>(new NotificationMessage(MembershipNotFoundMsg)); return; } }