public ActionResult Formulations_New(FORMULATION newFormulation) { try { BLTServiceCaller serviceCaller = BLTServiceCaller.Instance; var request = new RestRequest(Method.POST); request.Resource = "/Formulations"; request.RequestFormat = DataFormat.Xml; request.AddHeader("Content-Type", "application/xml"); //Use extended serializer BLTWebSerializer serializer = new BLTWebSerializer(); request.AddParameter("application/xml", serializer.Serialize<FORMULATION>(newFormulation), ParameterType.RequestBody); FORMULATION createdFormulation = serviceCaller.Execute<FORMULATION>(request); //now activate it for use //request = new RestRequest(); //request.Resource = "/Formulations/{entityID}/Activate?ActiveDate={date}"; //request.RootElement = "FORMULATION"; //request.AddParameter("entityID", createdFormulation.ID, ParameterType.UrlSegment); //FORMULATION activatedMod = serviceCaller.Execute<FORMULATION>(request); return RedirectToAction("../Parts/Index"); } catch (Exception e) { return View(e.ToString()); } }
public ActionResult Formulations_Edit(int id, FORMULATION editedFormulation) { BLTServiceCaller serviceCaller = BLTServiceCaller.Instance; var request = new RestRequest(Method.POST); request.Resource = "/Formulations/{entityID}"; request.RequestFormat = DataFormat.Xml; request.AddParameter("entityID", id, ParameterType.UrlSegment); request.AddHeader("X-HTTP-Method-Override", "PUT"); //Use extended serializer BLTWebSerializer serializer = new BLTWebSerializer(); request.AddParameter("application/xml", serializer.Serialize<FORMULATION>(editedFormulation), ParameterType.RequestBody); FORMULATION updatedFormulation = serviceCaller.Execute<FORMULATION>(request); //update the AI and go back to the AI index return RedirectToAction("Index"); }