Exemple #1
0
        /// <summary>
        /// The add user.
        /// </summary>
        /// <param name="emailAddress">
        /// The email address.
        /// </param>
        /// <param name="displayName">
        /// The display name.
        /// </param>
        /// <param name="activationTicket">
        /// The activation ticket.
        /// </param>
        /// <returns>
        /// The <see cref="bool"/>.
        /// </returns>
        public bool AddUser(string emailAddress, string displayName, string activationTicket)
        {
            bool status = false;
            UserEntity item = this.userTable.SingleOrDefault(u => u.EmailAddress == emailAddress);

            if (item == null)
            {
                var user = new UserEntity
                               {
                                   UserName = string.Empty,
                                   DisplayName = displayName,
                                   Password = string.Empty,
                                   UserCode = string.Empty,
                                   EmailAddress = emailAddress,
                                   ActiveStatus = null,
                                   ActivationKey = activationTicket
                               };

                this.userTable.InsertOnSubmit(user);
                this.Context.SubmitChanges();

                status = true;
            }
            else
            {
                if (item.ID != 1)
                {
                    item.DisplayName = displayName;
                    item.ActivationKey = activationTicket;

                    this.Context.SubmitChanges();

                    status = true;
                }
            }

            return status;
        }
Exemple #2
0
        /// <summary>
        /// The update user.
        /// </summary>
        /// <param name="userEntity">
        /// The user entity.
        /// </param>
        public void UpdateUser(UserEntity userEntity)
        {
            UserEntity user = this.userTable.SingleOrDefault(u => u.ID == userEntity.ID);
            if (user != null)
            {
                user.Password = userEntity.Password;
                user.UserCode = userEntity.UserCode;

                this.Context.SubmitChanges();
            }
        }
Exemple #3
0
        /// <summary>
        /// The update profile.
        /// </summary>
        /// <param name="userEntity">
        /// The user entity.
        /// </param>
        /// <returns>
        /// The <see cref="bool"/>.
        /// </returns>
        public bool UpdateProfile(UserEntity userEntity)
        {
            UserEntity user = this.userTable.SingleOrDefault(u => u.ID == userEntity.ID);
            if (user != null)
            {
                if (string.IsNullOrEmpty(user.UserName))
                {
                    user.UserName = userEntity.UserName;
                }

                user.EmailAddress = userEntity.EmailAddress;
                user.DisplayName = userEntity.DisplayName;

                if (userEntity.Password != null && userEntity.UserCode != null)
                {
                    user.Password = userEntity.Password;
                    user.UserCode = userEntity.UserCode;
                }

                if (userEntity.ActiveStatus.HasValue)
                {
                    user.ActiveStatus = userEntity.ActiveStatus;
                }

                user.ActivationKey = string.Empty;
                user.UserSite = userEntity.UserSite;

                this.Context.SubmitChanges();
                return true;
            }

            return false;
        }