示例#1
0
        public ActionResult CropUse_New(CROP_USE newCropUse)
        {
            try
            {
                BLTServiceCaller serviceCaller = BLTServiceCaller.Instance;
                var request = new RestRequest(Method.POST);

                request.Resource = "/CropUses";
                request.RequestFormat = DataFormat.Xml;
                request.AddHeader("Content-Type", "application/xml");
                //Use extended serializer
                BLTWebSerializer serializer = new BLTWebSerializer();
                request.AddParameter("application/xml", serializer.Serialize<CROP_USE>(newCropUse), ParameterType.RequestBody);
                CROP_USE createdCU = serviceCaller.Execute<CROP_USE>(request);

                return RedirectToAction("../Parts/Index");
            }
            catch (Exception e)
            {
                return View(e.ToString());
            }
        }
示例#2
0
        public ActionResult CropUse_Edit(int id, CROP_USE editedCropUse)
        {
            BLTServiceCaller serviceCaller = BLTServiceCaller.Instance;
            var request = new RestRequest(Method.POST);
            request.Resource = "/CropUses/{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<CROP_USE>(editedCropUse), ParameterType.RequestBody);
            CROP_USE updatedCropUse = serviceCaller.Execute<CROP_USE>(request);

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