コード例 #1
0
        /// <summary>
        /// Duplicates GreyFoxUser object into a database; may or may not be the same database
        /// as the parent object.
        /// </summary>
        /// <returns> A new GreyFoxUser object reflecting the replicated GreyFoxUser object.</returns>
        public GreyFoxUser Duplicate()
        {
            lock (this)
            {
                GreyFoxUser clonedGreyFoxUser = this.Clone();

                // Insert must be called after children are replicated!
                clonedGreyFoxUser.iD       = GreyFoxUserManager._insert(clonedGreyFoxUser);
                clonedGreyFoxUser.isSynced = true;
                return(clonedGreyFoxUser);
            }
        }
コード例 #2
0
        /// <summary>
        /// Saves the GreyFoxUser object state to the database.
        /// </summary>
        public int Save()
        {
            lock (this)
            {
                if (contact != null)
                {
                    contact.Save();
                }
                if (roles != null)
                {
                    foreach (GreyFoxRole item in roles)
                    {
                        item.Save();
                    }
                }

                if (isSynced)
                {
                    return(iD);
                }

                if (iD == -1)
                {
                    throw (new Exception("Invalid record; cannot be saved."));
                }
                if (iD == 0)
                {
                    iD = GreyFoxUserManager._insert(this);
                }
                else
                {
                    GreyFoxUserManager._update(this);
                }
                isSynced = iD != -1;
            }
            return(iD);
        }