Exemplo n.º 1
0
        public ActionResult AI_Class_New(AI_CLASS newAIClass)
        {
            try
            {
                BLTServiceCaller serviceCaller = BLTServiceCaller.Instance;
                var request = new RestRequest(Method.POST);
                request.Resource = "/AIClasses";
                request.RequestFormat = DataFormat.Xml;
                request.AddHeader("Content-Type", "application/xml");
                //Use extended serializer
                BLTWebSerializer serializer = new BLTWebSerializer();
                request.AddParameter("application/xml", serializer.Serialize<AI_CLASS>(newAIClass), ParameterType.RequestBody);

                AI_CLASS createdAIclass = serviceCaller.Execute<AI_CLASS>(request);

                ////now activate it for use
                //request = new RestRequest();
                //request.Resource = "/AIClasses/{entityID}/Activate?ActiveDate={date}";
                //request.RootElement = "AI_CLASS";
                //request.AddParameter("entityID", createdAIclass.ID, ParameterType.UrlSegment);
                //AI_CLASS activatedaiClass = serviceCaller.Execute<AI_CLASS>(request);

                return RedirectToAction("../Parts/Index");
            }
            catch (Exception e)
            {
                return View(e.ToString());
            }
        }
Exemplo n.º 2
0
        public ActionResult AI_Class_Edit(int id, AI_CLASS editedAIClass)
        {
            BLTServiceCaller serviceCaller = BLTServiceCaller.Instance;
            var request = new RestRequest(Method.POST);
            request.Resource = "/AIClasses/{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<AI_CLASS>(editedAIClass), ParameterType.RequestBody);
            AI_CLASS updatedAIClass = serviceCaller.Execute<AI_CLASS>(request);

            //update the AI and go back to the AI index
            return RedirectToAction("Index");
        }