Example #1
0
        public MembersDs.MembersRow AddMember(string userName,
                                              string email, string AlternateEmail,
                                              string password,
                                              string SecretQuestion, string SecretAnswer,
                                              string title,
                                              string firstName, string middleName, string lastName,
                                              Gender?gender, DateTime?dateOfBirth, int?status, int Privacy,
                                              string Comments, string PrivateComments, int?ChangedBy, bool?JoinNewsletter, string FullName, string NativeFullName)
        {
            string cond = "";

            if (email == "*****@*****.**")
            {
                cond = string.Format("Username='******'",
                                     StringUtils.SQLEncode(userName));
            }
            else
            {
                cond = string.Format("UserName='******' or Email='{1}'",
                                     StringUtils.SQLEncode(userName),
                                     StringUtils.SQLEncode(email));
            }

            if (GetMembers(cond).Rows.Count > 0)
            {
                if (email != null && email.Trim() != "")
                {
                    ErrorContext.Add("validation", ContentManager.ErrorMsg(Errors.UserAlreadyExists));
                    return(null);
                }
            }

            MembersDsTableAdapters.MembersTableAdapter adp = new lw.Members.MembersDsTableAdapters.MembersTableAdapter();
            MembersDs.MembersDataTable dt = adp.AddMember(
                System.Guid.NewGuid(),
                userName, EncryptPassword(password), status,
                title,
                firstName, middleName, lastName, (short?)gender, email, AlternateEmail,
                dateOfBirth,
                DateTime.Now, DateTime.Now, DateTime.Now, false, SecretQuestion,
                SecretAnswer, ChangedBy, JoinNewsletter, Privacy, FullName, NativeFullName);
            return((MembersDs.MembersRow)dt.Rows[0]);
        }
Example #2
0
 /*
  * public int UpdateMember(int MemberId, string userName,
  * string password,
  * string email,
  * string SecretQuestion, string SecretAnswer, string firstName,
  * string lastName, UserStatus stat, int ChangedBy)
  * {
  *      return UpdateMember(MemberId, userName, password, email, SecretQuestion, SecretAnswer, firstName, lastName, stat, ChangedBy);
  * }
  */
 public void DeleteMember(int MemberId)
 {
     lw.Members.MembersDsTableAdapters.MembersTableAdapter t = new lw.Members.MembersDsTableAdapters.MembersTableAdapter();
     t.DeleteMember(MemberId);
 }
Example #3
0
        public int UpdateMember(int MemberId, string userName,
                                string password,
                                string email, string AlternateEmail,
                                string SecretQuestion, string SecretAnswer,
                                string title,
                                string firstName,
                                string middleName,
                                string lastName, Gender?gender,
                                DateTime?dateOfBirth,
                                int?status, int?ChangedBy,
                                bool?JoinNewsletter,
                                string PrivateComments, string Comments, string FullName)
        {
            /* or Email='{1}' */
            string cond = string.Format("(UserName='******' or Email='{1}') and MemberId<>{2}",
                                        StringUtils.SQLEncode(userName),
                                        StringUtils.SQLEncode(email),
                                        MemberId);

            if (GetMembers(cond).Rows.Count > 0 && email != "")
            {
                ErrorContext.Add("validation", ContentManager.ErrorMsg(Errors.UserAlreadyExists));
                return(-1);
            }
            MembersDsTableAdapters.MembersTableAdapter adp = new lw.Members.MembersDsTableAdapters.MembersTableAdapter();

            MembersDs.MembersRow member = (MembersDs.MembersRow) this.GetMember(MemberId);

            member.UserName = userName;
            member.Email    = email;

            if (!string.IsNullOrEmpty(password))
            {
                member.Password = EncryptPassword(password);
            }

            if (AlternateEmail != null)
            {
                member.AlternateEmail = AlternateEmail;
            }

            if (SecretQuestion != null)
            {
                member.SecretQuestion = SecretQuestion;
            }

            if (SecretAnswer != null)
            {
                member.SecretQuestionAnswer = SecretAnswer;
            }

            if (title != null)
            {
                member.Title = title;
            }

            if (firstName != null)
            {
                member.FirstName = firstName;
            }

            if (lastName != null)
            {
                member.LastName = lastName;
            }

            if (gender != null)
            {
                member.Gender = (short)gender;
            }

            if (dateOfBirth != null)
            {
                member.DateOfBirth = dateOfBirth.Value;
            }

            if (status != null)
            {
                member.Status = status.Value;
            }

            if (JoinNewsletter != null)
            {
                member.JoinNewsletter = JoinNewsletter.Value;
            }

            if (ChangedBy != null)
            {
                member.ChangedBy = ChangedBy.Value;
            }

            if (PrivateComments != null)
            {
                member.PrivateComments = PrivateComments;
            }

            if (Comments != null)
            {
                member.Comments = Comments;
            }

            if (middleName != null)
            {
                member.MiddleName = middleName;
            }

            member.LastModified = DateTime.Now;

            return(adp.Update(member));
        }