public ActionResult Create(int Id = 0, int consult = 0)
        {
            var permission = PermissionHelper.GetRoleObjectPermission(SessionHelper.Role, 146);

            ViewBag.Permission = permission;
            var varSpartan_BR_Operator_Type = new Spartan_BR_Operator_TypeModel();



            if (Convert.ToString(Id) != "0" && Convert.ToString(Id) != "-1")
            {
                if (!_tokenManager.GenerateToken())
                {
                    return(Json(null, JsonRequestBehavior.AllowGet));
                }
                _ISpartan_BR_Operator_TypeApiConsumer.SetAuthHeader(_tokenManager.Token);
                var Spartan_BR_Operator_TypeData = _ISpartan_BR_Operator_TypeApiConsumer.GetByKeyComplete(Id).Resource.Spartan_BR_Operator_Types[0];
                if (Spartan_BR_Operator_TypeData == null)
                {
                    return(HttpNotFound());
                }

                varSpartan_BR_Operator_Type = new Spartan_BR_Operator_TypeModel
                {
                    OperatorTypeId = Spartan_BR_Operator_TypeData.OperatorTypeId
                    , Description  = Spartan_BR_Operator_TypeData.Description
                    , Presentation_Control_Type            = Spartan_BR_Operator_TypeData.Presentation_Control_Type
                    , Presentation_Control_TypeDescription = Spartan_BR_Operator_TypeData.Presentation_Control_Type_Spartan_BR_Presentation_Control_Type.Description
                    , Query_for_Fill_Condition             = Spartan_BR_Operator_TypeData.Query_for_Fill_Condition
                    , Code_for_Fill_Condition = Spartan_BR_Operator_TypeData.Code_for_Fill_Condition
                    , Implementation_Code     = Spartan_BR_Operator_TypeData.Implementation_Code
                };
            }
            if (!_tokenManager.GenerateToken())
            {
                return(Json(null, JsonRequestBehavior.AllowGet));
            }

            _ISpartan_BR_Presentation_Control_TypeApiConsumer.SetAuthHeader(_tokenManager.Token);
            var Spartan_BR_Presentation_Control_Types = _ISpartan_BR_Presentation_Control_TypeApiConsumer.SelAll(true);

            if (Spartan_BR_Presentation_Control_Types != null && Spartan_BR_Presentation_Control_Types.Resource != null)
            {
                ViewBag.Spartan_BR_Presentation_Control_Types = Spartan_BR_Presentation_Control_Types.Resource.Select(m => new SelectListItem
                {
                    Text = m.Description.ToString(), Value = Convert.ToString(m.PresentationControlTypeId)
                }).ToList();
            }


            ViewBag.Consult = consult == 1;
            return(View(varSpartan_BR_Operator_Type));
        }
        public ActionResult Post(Spartan_BR_Operator_TypeModel varSpartan_BR_Operator_Type)
        {
            try
            {
                if (!_tokenManager.GenerateToken())
                {
                    return(Json(null, JsonRequestBehavior.AllowGet));
                }
                _ISpartan_BR_Operator_TypeApiConsumer.SetAuthHeader(_tokenManager.Token);



                var result = "0";
                var Spartan_BR_Operator_TypeInfo = new Spartan_BR_Operator_Type
                {
                    OperatorTypeId = varSpartan_BR_Operator_Type.OperatorTypeId
                    , Description  = varSpartan_BR_Operator_Type.Description
                    , Presentation_Control_Type = varSpartan_BR_Operator_Type.Presentation_Control_Type
                    , Query_for_Fill_Condition  = varSpartan_BR_Operator_Type.Query_for_Fill_Condition
                    , Code_for_Fill_Condition   = varSpartan_BR_Operator_Type.Code_for_Fill_Condition
                    , Implementation_Code       = varSpartan_BR_Operator_Type.Implementation_Code
                };

                result = varSpartan_BR_Operator_Type.OperatorTypeId.ToString() != "0" ?
                         _ISpartan_BR_Operator_TypeApiConsumer.Update(Spartan_BR_Operator_TypeInfo, null, null).Resource.ToString() :
                         _ISpartan_BR_Operator_TypeApiConsumer.Insert(Spartan_BR_Operator_TypeInfo, null, null).Resource.ToString();

                if (varSpartan_BR_Operator_Type.OperatorTypeId.ToString() != "0")
                {
                    result = varSpartan_BR_Operator_Type.OperatorTypeId.ToString();
                }

                return(Json(result, JsonRequestBehavior.AllowGet));
            }
            catch (ServiceException)
            {
                return(Json(false, JsonRequestBehavior.AllowGet));
            }
        }