Example #1
0
        public Task Get <AsanaT>(AsanaWorkspace arg1, AsanaCollectionResponseEventHandler callback) where AsanaT : AsanaObject
        {
            AsanaRequest request = default(AsanaRequest);

            if (typeof(AsanaT) == typeof(AsanaUser))
            {
                request = GetBaseRequest(AsanaFunction.GetFunction(Function.GetUsersInWorkspace), arg1);
                return(request.Go((o, h) => PackAndSendResponseCollection <AsanaUser>(o, callback), ErrorCallback));
            }


            if (typeof(AsanaT) == typeof(AsanaProject))
            {
                request = GetBaseRequest(AsanaFunction.GetFunction(Function.GetProjectsInWorkspace), arg1);
                return(request.Go((o, h) => PackAndSendResponseCollection <AsanaProject>(o, callback), ErrorCallback));
            }


            if (typeof(AsanaT) == typeof(AsanaTag))
            {
                request = GetBaseRequest(AsanaFunction.GetFunction(Function.GetTagsInWorkspace), arg1);
                return(request.Go((o, h) => PackAndSendResponseCollection <AsanaTag>(o, callback), ErrorCallback));
            }


            if (typeof(AsanaT) == typeof(AsanaTeam))
            {
                request = GetBaseRequest(AsanaFunction.GetFunction(Function.GetTeamsInWorkspace), arg1);
                return(request.Go((o, h) => PackAndSendResponseCollection <AsanaTeam>(o, callback), ErrorCallback));
            }


            throw new TypeAccessException("Unknown type for this request: " + typeof(AsanaT).Name);
        }
Example #2
0
        /// <summary>
        /// Tells asana to delete the specified object
        /// </summary>
        /// <param name="obj"></param>
        internal Task Delete <T>(T obj) where T : AsanaObject
        {
            AsanaFunction func;

            IAsanaData idata = obj as IAsanaData;

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

            AsanaRequest             request = null;
            AsanaFunctionAssociation afa     = AsanaFunction.GetFunctionAssociation(obj.GetType());

            if (idata.IsObjectLocal == false)
            {
                func = afa.Delete;
            }
            else
            {
                throw new Exception("Object is local, cannot delete.");
            }

            if (Object.ReferenceEquals(func, null))
            {
                throw new NotImplementedException("This object cannot delete itself.");
            }

            request = GetBaseRequest(func, obj);
            return(request.Go((o, h) => RepackAndCallback(o, obj), ErrorCallback));
        }
Example #3
0
        public Task Get <AsanaT>(AsanaTask arg1, AsanaCollectionResponseEventHandler callback) where AsanaT : AsanaObject
        {
            AsanaRequest request = default(AsanaRequest);

            if (typeof(AsanaT) == typeof(AsanaStory))
            {
                request = GetBaseRequest(AsanaFunction.GetFunction(Function.GetStoriesInTask), arg1);
                return(request.Go((o, h) => PackAndSendResponseCollection <AsanaStory>(o, callback), ErrorCallback));
            }


            if (typeof(AsanaT) == typeof(AsanaProject))
            {
                request = GetBaseRequest(AsanaFunction.GetFunction(Function.GetProjectsOnATask), arg1);
                return(request.Go((o, h) => PackAndSendResponseCollection <AsanaProject>(o, callback), ErrorCallback));
            }


            throw new TypeAccessException("Unknown type for this request: " + typeof(AsanaT).Name);
        }
Example #4
0
        public Task Get <AsanaT>(AsanaTask arg1, String arg2, AsanaResponseEventHandler callback) where AsanaT : AsanaObject
        {
            AsanaRequest request = default(AsanaRequest);

            if (typeof(AsanaT) == typeof(AsanaEvent))
            {
                request = GetBaseRequest(AsanaFunction.GetFunction(Function.GetEventsInTask), arg1, arg2);
                return(request.Go((o, h) => PackAndSendResponse <AsanaEvent>(o, callback), ErrorCallback));
            }


            throw new TypeAccessException("Unknown type for this request: " + typeof(AsanaT).Name);
        }
Example #5
0
        public Task Get <AsanaT>(Int64 arg1, AsanaResponseEventHandler callback) where AsanaT : AsanaObject
        {
            AsanaRequest request = default(AsanaRequest);

            if (typeof(AsanaT) == typeof(AsanaUser))
            {
                request = GetBaseRequest(AsanaFunction.GetFunction(Function.GetUserById), arg1);
                return(request.Go((o, h) => PackAndSendResponse <AsanaUser>(o, callback), ErrorCallback));
            }


            if (typeof(AsanaT) == typeof(AsanaWorkspace))
            {
                request = GetBaseRequest(AsanaFunction.GetFunction(Function.GetWorkspaceById), arg1);
                return(request.Go((o, h) => PackAndSendResponse <AsanaWorkspace>(o, callback), ErrorCallback));
            }


            if (typeof(AsanaT) == typeof(AsanaTask))
            {
                request = GetBaseRequest(AsanaFunction.GetFunction(Function.GetTaskById), arg1);
                return(request.Go((o, h) => PackAndSendResponse <AsanaTask>(o, callback), ErrorCallback));
            }


            if (typeof(AsanaT) == typeof(AsanaStory))
            {
                request = GetBaseRequest(AsanaFunction.GetFunction(Function.GetStoryById), arg1);
                return(request.Go((o, h) => PackAndSendResponse <AsanaStory>(o, callback), ErrorCallback));
            }


            if (typeof(AsanaT) == typeof(AsanaProject))
            {
                request = GetBaseRequest(AsanaFunction.GetFunction(Function.GetProjectById), arg1);
                return(request.Go((o, h) => PackAndSendResponse <AsanaProject>(o, callback), ErrorCallback));
            }


            if (typeof(AsanaT) == typeof(AsanaTag))
            {
                request = GetBaseRequest(AsanaFunction.GetFunction(Function.GetTagById), arg1);
                return(request.Go((o, h) => PackAndSendResponse <AsanaTag>(o, callback), ErrorCallback));
            }


            throw new TypeAccessException("Unknown type for this request: " + typeof(AsanaT).Name);
        }
Example #6
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));
        }