Club Manager : Create Member : Model

Assuming last run was a great success now we can proceed with implementing other functionalities. As we discussed in Club Manager : Discussing Dependency we next create a new Member functionality and later implement Member listing.

Let us first discuss about the properties of members. First of all we need to store basic details of member like Name, Contact Number, Email, Address, Date of Birth, Membership joining date then his membership information and Club related properties of Member and so on. We can list them as below:

  • Basic Details of Member:
    • MemberName: Full name of the member, you can break it into First Name, Middle Name, Last name and so on.
    • ContactNo: Contact number of the member.
    • EmailID: Email id of the member.
    • Address: Correspondence address of the member, this can also be broken.
    • ZIPCode: Postal code of the member ie ZIP or PIN
    • DateOfBirth: Date of Birth of member.
  • Membership Detail:
    • DateOfJoining: Membership joining date of member.
    • MemberShipPlan: Which plan member has taken.
    • PaymentDueDate: Next payment is due on.
    • LastFeePaidOn: Last payment was done on.
    • BalanceAmount: Balance Amount if any.
  • Other Information:
    • _id: MembershipID
    • IsActive: If the member is active or not
    • Comment: Some comment specific to user
    • ProfilePictureLocation : Location of User Profile Picture

Club Properties: Club may also decide to store some specific information and the same vary from club to club. e.g. Gym may like to store Height, Weight and so on while Sports Complex would like to store timing, sportsInterested and so on. So we give the functionality to store 8 such properties and the same will be stored in Property<n> where n is from 1 to 8.

So add a new class in ClubManager.Model named Member.cs and find below the listing of the same.

using System;
using System.Xml.Linq;
using Core.Configuration;
 
namespace ClubManager.Model
{
    public class Member
    {
        #region Basic Details of Member
 
        /// <summary>
        /// Name of the member
        /// </summary>
        public string MemberName { get; set; }
 
        /// <summary>
        /// Contact number of the member
        /// </summary>
        public string ContactNo { get; set; }
 
        /// <summary>
        /// EmailID of the member
        /// </summary>
        public string EmailID { get; set; }
 
        /// <summary>
        /// Address of the member
        /// </summary>
        public string Address { get; set; }
 
        /// <summary>
        /// ZIP/PIN code of the member
        /// </summary>
        public string ZIPCode { get; set; }
 
        /// <summary>
        /// Date of birth of member
        /// </summary>
        public DateTime DateOfBirth { get; set; }
 
        #endregion Basic Details of Member
 
        #region MemberShipDetail
 
        /// <summary>
        /// MemberShipPlan opted by member
        /// </summary>
        public string MemberShipPlan { get; set; }
 
        /// <summary>
        /// Joining date of member
        /// </summary>
        public DateTime DateOfJoining { get; set; }
 
        /// <summary>
        /// Next payment is due on
        /// </summary>
        public DateTime PaymentDueDate { get; set; }
 
        /// <summary>
        /// Fee was last paid on
        /// </summary>
        public DateTime LastFeePaidOn { get; set; }
 
        /// <summary>
        /// Balance amount if any
        /// </summary>
        public double BalanceAmount { get; set; }
        #endregion MemberShipDetail
 
        #region Other Information
 
        /// <summary>
        /// Member ID
        /// </summary>
        public string _id { get; set; }
 
        /// <summary>
        /// If Member is active or not.
        /// </summary>
        public bool IsActive { get; set; }
 
        /// <summary>
        /// Some information specific to this user
        /// </summary>
        public string Comment { get; set; }
 
        /// <summary>
        /// Location of User's Profile Picture
        /// </summary>
        public string ProfilePictureLocation { get; set; }
        #endregion Other Information
 
        #region Club Properties
 
        /// <summary>
        /// Property1 response of the Member
        /// </summary>
        public string Property1 { get; set; }
 
        /// <summary>
        /// Property2 response of the Member
        /// </summary>
        public string Property2 { get; set; }
 
        /// <summary>
        /// Property3 response of the Member
        /// </summary>
        public string Property3 { get; set; }
 
        /// <summary>
        /// Property4 response of the Member
        /// </summary>
        public string Property4 { get; set; }
 
        /// <summary>
        /// Property5 response of the Member
        /// </summary>
        public string Property5 { get; set; }
 
        /// <summary>
        /// Property6 response of the Member
        /// </summary>
        public string Property6 { get; set; }
 
        /// <summary>
        /// Property7 response of the Member
        /// </summary>
        public string Property7 { get; set; }
 
        /// <summary>
        /// Property8 response of the Member
        /// </summary>
        public string Property8 { get; set; }
        #endregion Club Properties
 
        #region Overridden Methods
 
        /// <summary>
        /// String representation of the Member
        /// </summary>
        /// <returns>Name of the Member</returns>
        public override string ToString()
        {
            return this.MemberName;
        }
 
        #endregion Overridden Methods
    }
}

But where do we store the Property names? As usual it will be stored in our Config.xml and we will read property names as soon as the same is required for which there is not any best place than static constructor of our Member class. We will store this in a node MemberProperty. For the sake of testing we add Height, Weight, Blood Group, RH Factor, Hobby, Allergy, Timing, Duration as our Club Property. Open Config.xml add a node MemberProperty and within this node create separate entries for all the said properties as Property<n>.

<?xml version="1.0" encoding="utf-8" ?>
<Club>
  <DB>
    <Type>Mongo</Type>
    <Host>127.0.0.1</Host>
    <Port>27017</Port>
    <Auth>False</Auth>
    <Username></Username>
    <Password></Password>
    <DBName>MyClub</DBName>
    <Prefix></Prefix>
    <Suffix></Suffix>
    <ConfigTable>MyConfig</ConfigTable>
  </DB>
  <MemberProperty>
    <Property1>Height</Property1>
    <Property2>Weight</Property2>
    <Property3>Blood Group</Property3>
    <Property4>RH Factor</Property4>
    <Property5>Hobby</Property5>
    <Property6>Allergy</Property6>
    <Property7>Timing</Property7>
    <Property8>Duration</Property8>
  </MemberProperty>
</Club>

How about reading these properties in our Member.cs

using System;
using System.Xml.Linq;
using Core.Configuration;
 
namespace ClubManager.Model
{
    public class Member
    {
        #region XML Keys
        public static string MEMBER_PROPERTY_KEY = "MemberProperty";
        public static string MEMBER_PROPERTY = "Property{0}";
        #endregion XML Keys
 
        #region Property Names
        public static string[] PropertyNames = new string[] { null, null, null, null, null, null, null, null };
        #endregion Property Names
 
        #region Constructors
 
        static Member()
        {
            XElement ele = ConfigurationManager.ConfigValue[MEMBER_PROPERTY_KEY];
            for (int i = 1; i &lt;= 8; i++)
            {
                if (ele.Element(string.Format(MEMBER_PROPERTY, i.ToString())) != null)
                {
                    PropertyNames[i - 1] = ele.Element(string.Format(MEMBER_PROPERTY, i.ToString())).Value;
                }
            }
        }
 
        #endregion Constructors
 
        //Other class members as defined earlier
    }
}

Leave a Reply