Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

To Insert and Update data we have 2 ways

  • Insert or Update Single objectObject
  • Insert or Update List Objectof Objects

* Standard json format: is available for all client, especially client not using our support library like Apis - light and easy to use
**Non-standard json format: is still in json format but have some additional special properties processed by our DAL or OM, this json is usually generated by our lib : Winbooks.Serializer . Suitable for client using our DAL and OM dll to perform complicated task

A. Insert Single Object

This function is used for inserting single data object in API

a. Using HTTP

URL: { REST API Host } / app / { Winbooks OM } / { Code } / Folder/ { FolderCode } 
Method : POST
Header : 
    Authorization : Bearer {access_token}
    Content-Type : application/json
Body content : {object in json format}

...

b. Using Winbooks.Apis.Services

//CREATE SINGLE CUSTOMER
Customer newCustomer = new Customer();
newCustomer.MemoType = MemoType.Green;
newCustomer.Code = "ALICE" ;
newCustomer.Memo = "this memo is for customer Alice Wilder" ;
//CREATE MANDATORY OBJECT
newCustomer.Third = new Third();
newCustomer.Third.Code = "ALICE" ;
newCustomer.Third.Name = "Alice Wilder" ;
newCustomer.Third.WebSite = "www.alice-wilder.com" ;
//INSERT NEW CUSTOMER TO FOLDER PARFIWEB
bool isInsertSuccess = folderPARFIWEB.Insert<Customer>(newCustomer, 2 );

B. Insert List of Objects

This function is used to Insert or Update a list of objects.

a. Using HTTP

URL : { REST API Host } / app / { Winbooks OMS } / Folder / { FolderCode }
Method : POST
Header :
   Authorization : Bearer {access_token}
   Content-Type : application/json
Body Content: { list of object need to be inserted in json format}

...

**Note :With multiple objects, each json member in json array must have id/code

b. Using Winbooks.Apis.Services


Insert list Of Customers

for ( int i = 0; i < arrayStrings.Count(); i++)
{
     Customer cust = new Customer();
     cust.Code = arrayStrings[i];
     cust.IsGroupDeliveryAllowed = true ;
     cust.IsHidden = false ;
     cust.IsLocked = false ;
     cust.Third = new Third();
     cust.Third.Code = arrayStrings[i];
     cust.Third.Addresses = new List<Address>();
     lstCustomer.Add(cust);
}
// Insert List of Customer
EntitiesServices folderRESTAPIDEMO = new EntitiesServices(userCredential, "PARIWEB_DEMO" );
folderRESTAPIDEMO.InsertCollection(lstCustomer);