public ZohoInsertResponse InsertRecords <T>(IEnumerable <T> records) where T : ZohoEntity { AssertTypeIsNotAbstract(typeof(T)); AssertAllowInserts(typeof(T)); AssertAllowMultipleInserts(typeof(T), records); ZohoEntityCollection <T> collection; if (records is ZohoEntityCollection <T> ) { collection = (ZohoEntityCollection <T>)records; } else { collection = new ZohoEntityCollection <T>(); foreach (var record in records) { collection.Add(record); } } var moduleName = ModuleName(typeof(T)); var xmlData = collection.ToXmlString(); return(PostData(moduleName, "insertRecords", null, xmlData)); }
public void InsertMultipleRecords() { var client = CreateClient(); var entries = new ZohoEntityCollection <T>(); for (int i = 0; i < 3; i++) { entries.Add(CreateEntry(i)); } var response = client.InsertRecords(entries); Assert.AreEqual(3, response.RecordDetails.Count()); foreach (var detail in response.RecordDetails) { Console.Out.WriteLine("(ID = {0}) Created On {1} by {2}", detail.Id, detail.CreatedDate, detail.CreatedBy); } }
public ZohoBulkUpsertRepsonse <T> BulkUpsertRecords <T>(IList <T> records) where T : ZohoEntity { AssertTypeIsNotAbstract(typeof(T)); AssertAllowInserts(typeof(T)); AssertAllowMultipleInserts(typeof(T), records); var collection = new ZohoEntityCollection <T>(); foreach (var record in records) { collection.Add(record); } var moduleName = ModuleName(records.FirstOrDefault()); var xmlData = collection.ToXmlString(); this.DuplicateCheck = InsertDuplicateCheck.Update; var rawHtmlRepsonse = PostDataRaw(moduleName, "insertRecords", null, xmlData, 4, true); var response = new ZohoBulkUpsertRepsonse <T>(rawHtmlRepsonse, requestItems: records.ToList()); return(response); }