public JsonResult InsertOrder(string FullName, DateTime DateOfDeliver, string Status, PurchaseItemsVM[] purchaseItem, double amountDue) { var customer = iCustomer.GetCustomerList().Where(x => x.FullName == FullName).FirstOrDefault(); PurchaseOrderVM purchaseOrder = new PurchaseOrderVM(); if (customer == null) { return(Json("Customer does not exist", JsonRequestBehavior.AllowGet)); } else { if (customer.IsActive) { purchaseOrder.CustomerID = customer.ID; purchaseOrder.CustomerName = customer.FullName; purchaseOrder.DateOfDelivery = DateOfDeliver; purchaseOrder.AmountDue = amountDue; purchaseOrder.Status = Status; } else { return(Json("Customer is not active", JsonRequestBehavior.AllowGet)); } } List <string> auditChanges = new List <string>(); auditChanges.Add("Customer ID=\"" + purchaseOrder.CustomerID.ToString() + "\""); auditChanges.Add("Customer Name=\"" + purchaseOrder.CustomerName + "\""); auditChanges.Add("Date of Deliver=\"" + purchaseOrder.DateOfDelivery.ToString() + "\""); auditChanges.Add("Status=\"" + purchaseOrder.Status + "\""); List <PurchaseItemsVM> PurchaseItem = new List <PurchaseItemsVM>(); foreach (var item in purchaseItem) { PurchaseItem.Add(item); auditChanges.Add("SKU ID=\"" + item.SKUID + "\", Quantity=\"" + item.Quantity + "\""); } purchaseOrder.PurchaseItems = PurchaseItem; string result = iOrder.InsertPurchseOrder(purchaseOrder, auditChanges); return(Json(result, JsonRequestBehavior.AllowGet)); }