Ejemplo n.º 1
0
        } //end Update

        #endregion //Update



        #region Delete

        /// <summary>
        /// Deletes entities
        /// </summary>
        /// <param name="entity">entity to delete</param>
        /// <returns></returns>
        public bool Delete(Entities.Entity entity)
        {
            bool deletedEntity = false;

            if (!true)//entity.CanDelete)
            {
                throw new AutotaskNETException($"The {entity.GetType()} entity can not be deleted.");
            }
            else
            {
                //delete entity
                net.autotask.webservices.ATWSResponse resp = this._atws.delete(new net.autotask.webservices.Entity[] { entity.ToATWS() });
                if (resp.Errors.Length > 0)
                {
                    throw new AutotaskNETException(string.Join("\r\n", resp.Errors.Select(r => r.Message)));
                }
                else
                {
                    deletedEntity = true;
                }
            }
            return(deletedEntity);
        } //end Delete
Ejemplo n.º 2
0
        } //end Create

        #endregion //Create



        #region Update

        /// <summary>
        /// Updates the specified entity.
        /// </summary>
        /// <param name="entity">The entity to update.</param>
        /// <returns>the updated entity.</returns>
        /// <exception cref="AutotaskNETException">
        /// The entity cannot be updated.
        /// Response error.
        /// </exception>
        public Entities.Entity Update(Entities.Entity entity)
        {
            Entities.Entity updatedEntity = null;
            if (!true)//entity.CanUpdate)
            {
                throw new AutotaskNETException($"The {entity.GetType()} entity can not be updated.");
            }
            else
            {
                //update entity
                net.autotask.webservices.ATWSResponse resp = this._atws.update(new net.autotask.webservices.Entity[] { entity.ToATWS() });
                if (resp.Errors.Length > 0)
                {
                    throw new AutotaskNETException(string.Join("\r\n", resp.Errors.Select(r => r.Message)));
                }
                else
                {
                    updatedEntity = this.Query(entity.GetType(), new QueryFilter()
                    {
                        new Condition("id", ConditionOperation.Equals, entity.id)
                    }).FirstOrDefault();
                }
            }
            return(updatedEntity);
        } //end Update