Esempio n. 1
0
        public Student Save()
        {
            Database db = new Database("student");
            try
            {

                db.BeginTransaction();

                Boolean result = true;
                if (base.IsNew == true && IsSavable() == true)
                {
                    result = Insert(db);
                }
                else if (base.Deleted == true)
                {
                    result = Delete(db);
                }
                else if (base.IsNew == false && IsSavable() == true)
                {
                    result = Update(db);
                }
                base.IsDirty = false;
                base.IsNew = false;

                //SAVE THE CHILDREN
                if (result == true && _comments != null && _comments.IsSavable() == true)
                {
                    result = _comments.Save(db, base.Id);
                }

                if (result == true && _emails != null && _emails.IsSavable() == true)
                {
                    result = _emails.Save(db, base.Id);
                }
                if (result == true && _phones != null && _phones.IsSavable() == true)
                {
                    result = _phones.Save(db, base.Id);
                }
                if (result == true && _addresses != null && _addresses.IsSavable() == true)
                {
                    result = _addresses.Save(db, base.Id);
                }
                if (result == true && _classes != null && _classes.IsSavable() == true)
                {
                    result = _classes.Save(db, base.Id);
                }
                if (result == true)
                {
                    db.EndTransaction();
                }
                else
                {
                    db.RollBackTransaction();
                }
            }
            catch (Exception e)
            {
                db.RollBackTransaction();
                throw;
            }
            return this;
        }
Esempio n. 2
0
        public Book Save()
        {
            Database db = new Database("Books");
            db.BeginTransaction();
            Boolean result = true;

            if (base.IsNew == true && IsSavable() == true)
            {
                result = Insert(db);
            }
            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 && _ReviewList != null && _ReviewList.IsSavable() == true)
            {
                result = _ReviewList.Save(db, base.ID);
            }

            if (result == true)
            {
                db.EndTransaction();
            }
            else
            {
                db.RollBackTransaction();
            }

            return this;
        }
Esempio n. 3
0
        public User Save()
        {
            Database db = new Database("Books");
            db.BeginTransaction();
            Boolean result = true;
            if (base.IsNew == true && IsSavable() == true)
            {
                result = Insert(db);
            }
            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 && _books != null && _books.IsSavable() == true)
            {
                result = _books.Save(db, base.ID);
            }

            if (result == true && _userbooks != null && _userbooks.IsSavable() == true)
            {
                result = _userbooks.Save(db, _userbooks.List[_userbooks.List.Count - 1].UserID, _userbooks.List[_userbooks.List.Count - 1].BookID);
            }

            if (result == true)
            {
                db.EndTransaction();
            }
            else
            {
                db.RollBackTransaction();
            }
            return this;
        }