Ejemplo n.º 1
0
        public void DoesCreateMemberSetMemberId()
        {
            IMember member = new Member("ent", DateTime.Now, "mand", "2| resten", 0, "234234", "wefwef", DateTime.Now, "hervej", 5230, "odense", true);
            member = MemberPersistence.CreateMember(member);

            Assert.AreNotEqual(0, member.MemberId);
        }
        public static List<IMember> RetrieveMembers()
        {
            List<IMember> memberList = new List<IMember>();

            if (Connect())
            {

                try
                {

                    SqlCommand Command = new SqlCommand("fif_member_retieve", Connection);
                    Command.CommandType = CommandType.StoredProcedure;

                    SqlDataReader Reader = Command.ExecuteReader();

                    while (Reader.Read())
                    {

                        // Members Properties
                        int memberId = int.Parse(Reader["member_id"].ToString());
                        string memberName = Reader["name"].ToString();
                        DateTime birthday = DateTime.Parse(Reader["birthday"].ToString());
                        string gender = Reader["gender"].ToString();
                        int passPortNumber;
                        int.TryParse(Reader["passport_number"].ToString(), out passPortNumber);
                        string mobile = Reader["mobile"].ToString();
                        string email = Reader["email"].ToString();
                        DateTime dateOfEnrollment = DateTime.Parse(Reader["date_of_enrollment"].ToString());
                        bool activated = bool.Parse(Reader["activated"].ToString());

                        // Address Properties
                        string street = Reader["address"].ToString();
                        string city = Reader["city"].ToString();
                        int zipcode = int.Parse(Reader["zipcode"].ToString());

                        //Degree String
                        int degreeId = int.Parse(Reader["degree_id"].ToString());
                        int kup = int.Parse(Reader["kup"].ToString());
                        string degreeName = Reader["degree_id"].ToString();
                        string degree = degreeId + "|" + " " + degreeName + ", Kup: " + kup;

                        IMember thisMember = new Member(memberName, birthday, gender, degree, passPortNumber, mobile, email, dateOfEnrollment, street, zipcode, city, activated, memberId);
                        memberList.Add(thisMember);

                    }
                    Disconnect();

                }
                catch
                {
                    Disconnect();
                    return null;
                }

            }

            return memberList;
        }
        public bool CreateMember(string name, DateTime birthday, string gender, int passportNumber, string mobile, string email,
            DateTime dateOfEnrollment, string street, int zipcode, string city, string degree)
        {
            IMember member = new Member(name, birthday, gender, degree, passportNumber, mobile, email, dateOfEnrollment, street,
                                        zipcode, city, true);
            if (!doesMemberWithSamePropertiesExist(member))
            {
                member = MemberPersistence.CreateMember(member);
                if (member != null)
                {
                    memberList.Add(member);
                    return true;
                }
            }

            return false;
        }
 public bool UpdateMember(int id, string name, DateTime birthday, string gender, int passportNumber, string mobile, string email, DateTime dateOfEnrollment, bool activated, string street, int zipcode, string city, string degree)
 {
     IMember newmember = new Member(name, birthday, gender, degree, passportNumber, mobile, email, dateOfEnrollment, street, zipcode, city, activated, id);
     IMember member = new Member(name, birthday, gender, degree, passportNumber, mobile, email, dateOfEnrollment, street, zipcode, city, activated, id);
     if (MemberPersistence.UpdateMember(member))
     {
         IMember memberInList = RetrieveSingleMember(member.MemberId);
         updateMemberProperties(memberInList, member);
         return true;
     }
     return false;
 }