/// <summary> /// Sets the value of the target object based on the given formPost values /// </summary> /// <param name="formPost"></param> /// <returns></returns> public override async Task <ActionResult> Set(FormPost formPost) { try { // Extract values from FormPost formPost.resultsToXml(); int id = formPost.parseInt("id", -1); int shared = formPost.parseInt("shared", 0); int isPublic = formPost.parseInt("isPublic", 0); // Retrieve the record from the database ObjectDBContext ctx = getObjectDbContext(); FormPost model = ctx.FormPosts.Single(m => m.id == id && (m.authorId == User.Identity.Name || m.shared == 1) ); formPost.setXml(); formPost.resultsToXml(); // Set new values int result = 0; model.xmlResults = formPost.xmlResults; model.jsonResults = formPost.jsonResults; model.formId = formPost.formId; model.shared = shared; model.isPublic = isPublic; // Save the object ctx.FormPosts.Add(model); ctx.Entry(model).State = System.Data.Entity.EntityState.Modified; // Critical result = ctx.SaveChanges(); // Return the success response along with the message body return(Json(new Payload(1, "FORMPOST", model))); //, JsonRequestBehavior.AllowGet // "Successfully set FORMPOST (" + model.id + "," + id + ")" } catch (Exception e) { return(Json(new Payload(0, e, "Unknown exception for FORMPOST<br><br>" + e.Message.ToString()))); // JsonRequestBehavior.AllowGet } }