Exemple #1
0
        /// <summary>
        /// Tells the asana object to save the specified object
        /// </summary>
        /// <param name="obj"></param>
        internal Task Save <T>(T obj, AsanaFunction func, Dictionary <string, object> data = null) where T : AsanaObject
        {
            IAsanaData idata = obj as IAsanaData;

            if (idata == null)
            {
                throw new NullReferenceException("All AsanaObjects must implement IAsanaData in order to Save themselves.");
            }

            if (data == null)
            {
                data = Parsing.Serialize(obj, true, !idata.IsObjectLocal);
            }
            AsanaRequest             request = null;
            AsanaFunctionAssociation afa     = AsanaFunction.GetFunctionAssociation(obj.GetType());

            if (func == null)
            {
                func = idata.IsObjectLocal ? afa.Create : afa.Update;
            }

            request = GetBaseRequestWithParams(func, data, obj);
            return(request.Go((o, h) => RepackAndCallback(o, obj), ErrorCallback));
        }