Exemplo n.º 1
0
        public async Task <JsonWorkItem> UpdateWorkItem(JsonWorkItem workItem)
        {
            JArray elements = JsonWorkItem.FieldsToJArray(workItem);
            string body     = ToJsonString(elements);
            var    exchange = StructuredHttpExchange.Patch(WitRestCalls.WorkItem, body);

            exchange.SetRoute("{id}", workItem.Id);
            JsonWorkItem result = await ProcessCollectionRequest(exchange, jObject =>
            {
                JsonWorkItem newWorkItem = JsonWorkItem.FromToken(jObject);
                return(newWorkItem);
            });

            return(result);
        }
        public void Patch_UnitTest()
        {
            String relativeRoute           = default(String);
            String body                    = default(String);
            StructuredHttpExchange _retVal = default(StructuredHttpExchange);

            ExecuteMethod(
                () => { return(GetInstance()); },
                instance =>
            {
                relativeRoute = default(String); //No Constructor
                body          = default(String); //No Constructor
                Patch_PreCondition(ref instance, ref relativeRoute, ref body);
            },
                instance => { _retVal = StructuredHttpExchange.Patch(relativeRoute, body); },
                instance => { Patch_PostValidate(instance, relativeRoute, body, _retVal); });
        }
Exemplo n.º 3
0
        /// <summary>
        /// Creates the work item.
        /// </summary>
        /// <param name="project">The project.</param>
        /// <param name="workItemType">Type of the work item.</param>
        /// <param name="workItem">The work item.</param>
        /// <param name="inPlaceUpdate">if set to <c>true</c> [in place update].</param>
        /// <returns>Task&lt;JsonWorkItem&gt;.</returns>
        public async Task <JsonWorkItem> CreateWorkItem(string project, string workItemType, JsonWorkItem workItem, bool inPlaceUpdate)
        {
            JArray elements = JsonWorkItem.FieldsToJArray(workItem);
            var    body     = ToJsonString(elements);
            var    exchange = StructuredHttpExchange.Patch(WitRestCalls.WorkItems1, body);

            exchange.SetRoute("{type}", workItemType.Replace(" ", "%20"));
            JsonWorkItem result = await ProcessProjectRequest(project, exchange, jObject =>
            {
                if (inPlaceUpdate)
                {
                    workItem.CaptureJson(jObject);
                    return(workItem);
                }
                var newWorkItem = JsonWorkItem.FromToken(jObject);
                return(newWorkItem);
            });

            return(result);
        }