Ejemplo n.º 1
0
        public Book Save(Database db, Guid userID)
        {
            _UserID = userID;
            Boolean result = true;

            if (base.IsNew == true && IsSavable() == true)
            {
                result = Insert(db);

                UserBook ub = new UserBook();
                ub.UserID  = userID;
                _UserBooks = new UserBookList();
                _UserBooks.List.Add(ub);
            }
            else if (base.Deleted == true)
            {
                result = Delete(db);
            }
            else if (base.IsNew == false && IsSavable() == true)
            {
                result = Update(db);
            }

            base.IsDirty = false;
            base.IsNew   = false;

            if (result == true && _UserBooks != null && _UserBooks.IsSavable() == true)
            {
                result = _UserBooks.Save(db, userID, base.ID);
            }

            return(this);
        }