public void CSOMApiCallBuilder_Test_BuildUpdateItemApiCall() { UpdateListItemRequest request = new UpdateListItemRequest("test-site-id", "test-web-id", "test-list-id", 1); request.FieldsToUpdate.Add( new CSOMItemField() { FieldName = "Test Field", FieldType = "String", FieldValue = "Test field value" }); CSOMApiCallBuilder builder = new CSOMApiCallBuilder(); builder.AddRequest(request); string xmlBody = builder.SerializeCSOMRequests(); Assert.AreEqual("<Request AddExpandoFieldTypeSuffix=\"true\" SchemaVersion=\"15.0.0.0\" LibraryVersion=\"16.0.0.0\" ApplicationName=\"pnp core sdk\" xmlns=\"http://schemas.microsoft.com/sharepoint/clientquery/2009\"><Actions><Method Name=\"SetFieldValue\" Id=\"4\" ObjectPathId=\"1\"><Parameters><Parameter Type=\"String\">Test Field</Parameter><Parameter Type=\"String\">Test field value</Parameter></Parameters></Method><Method Name=\"Update\" Id=\"5\" ObjectPathId=\"1\"></Method></Actions><ObjectPaths><Identity Id=\"1\" Name=\"121a659f-e03e-2000-4281-1212829d67dd|740c6a0b-85e2-48a0-a494-e0f1759d4aa7:site:test-site-id:web:test-web-id:list:test-list-id:item:1,1\" /></ObjectPaths></Request>", xmlBody); }
public void UpdateListItemRequest_Test_GetRequest() { UpdateListItemRequest request = new UpdateListItemRequest("test-site-id", "test-web-id", "test-list-id", 1); request.FieldsToUpdate.Add(new CSOMItemField() { FieldName = "Test Field", FieldType = "String", FieldValue = "Test field value" }); IIdProvider idProvider = new IteratorIdProvider(); List <ActionObjectPath> actionObjectPaths = request.GetRequest(idProvider); ActionObjectPath setFieldsActionPath = actionObjectPaths[0]; Assert.AreEqual("<Method Name=\"SetFieldValue\" Id=\"4\" ObjectPathId=\"1\"><Parameters><Parameter Type=\"String\">Test Field</Parameter><Parameter Type=\"String\">Test field value</Parameter></Parameters></Method>", setFieldsActionPath.Action.ToString()); ActionObjectPath actionObjectPath = actionObjectPaths[1]; Assert.AreEqual("<Method Name=\"Update\" Id=\"5\" ObjectPathId=\"1\"></Method>", actionObjectPath.Action.ToString()); Assert.AreEqual("<Identity Id=\"1\" Name=\"121a659f-e03e-2000-4281-1212829d67dd|740c6a0b-85e2-48a0-a494-e0f1759d4aa7:site:test-site-id:web:test-web-id:list:test-list-id:item:1,1\" />", actionObjectPath.ObjectPath.ToString()); }
public async Task <MessageOutputBase> UpdateListItem([FromBody] UpdateListItemRequest request) { MessageOutputBase result = null; request.UserName = GetCurrentUser(); await Execute(flow => { flow.StartRegisterFlow() .Add <CheckUserExistsStep>() .Add <CheckListExistsStep>() .Add <CheckListItemExistsStep>() .Add <UpdateListItemStep>(); flow. When <UserNotFoundStep, UserNotFoundParams>(notFound => { result = notFound.Response; }) .When <ListNotFoundStep, ListNotFoundParams>(notFound => { result = notFound.Response; }) .When <ListItemNotFoundStep, ListItemNotFoundParams>(notFound => { result = notFound.Response; }) .When <UpdateListItemStep, UpdateListItemParams>(update => { result = update.Response; }); }, request, error => { result = error; }); return(result); }