public static object AddOneBrand(string WebFormData) { var webFormData = JsonConvert.DeserializeObject <dynamic>(WebFormData); int newBrandId = 0; try { BrandManager brandManager = new BrandManager(); newBrandId = brandManager.AddOneBrand(webFormData); if (newBrandId > 0) { var response = new { newBrandId = newBrandId, status = "success", message = "Created a new brand record." }; return(response); //--- The following code is not needed. //--- because the function is configured to return an object (not a string) //string response = JsonConvert.SerializeObject(successResponse); } else { //Due to the simplicity of this example, this section is rarely tested. var response = new { newBrandId = 0, status = "fail", message = "Unable to save Brand record." }; return(response); } } catch (Exception ex) { var response = new { newBrandId = 0, status = "fail", message = "Unable to save student record. " + ex.Message }; return(response); } }//end of addOneBrand