public ActionResult Post(bool IsNew, Spartan_WorkFlow_ConditionModel varSpartan_WorkFlow_Condition)
        {
            try
            {
                //if (ModelState.IsValid)
                //{
                if (!_tokenManager.GenerateToken())
                {
                    return(Json(null, JsonRequestBehavior.AllowGet));
                }
                _ISpartan_WorkFlow_ConditionApiConsumer.SetAuthHeader(_tokenManager.Token);



                var result = "";
                var Spartan_WorkFlow_ConditionInfo = new Spartan_WorkFlow_Condition
                {
                    ConditionId   = varSpartan_WorkFlow_Condition.ConditionId
                    , Description = varSpartan_WorkFlow_Condition.Description
                };

                result = !IsNew?
                         _ISpartan_WorkFlow_ConditionApiConsumer.Update(Spartan_WorkFlow_ConditionInfo, null, null).Resource.ToString() :
                             _ISpartan_WorkFlow_ConditionApiConsumer.Insert(Spartan_WorkFlow_ConditionInfo, null, null).Resource.ToString();

                Session["KeyValueInserted"] = result;
                return(Json(result, JsonRequestBehavior.AllowGet));
                //}
                //return Json(false, JsonRequestBehavior.AllowGet);
            }
            catch (ServiceException ex)
            {
                return(Json(false, JsonRequestBehavior.AllowGet));
            }
        }
        public ActionResult Create(short Id = 0, int consult = 0)
        {
            var permission = PermissionHelper.GetRoleObjectPermission(SessionHelper.Role, 130);

            ViewBag.Permission = permission;
            var varSpartan_WorkFlow_Condition = new Spartan_WorkFlow_ConditionModel();

            ViewBag.ObjectId  = "130";
            ViewBag.Operation = "New";

            ViewBag.IsNew = true;



            if ((Id.GetType() == typeof(string) && Id.ToString() != "") || ((Id.GetType() == typeof(int) || Id.GetType() == typeof(Int16) || Id.GetType() == typeof(Int32) || Id.GetType() == typeof(Int64) || Id.GetType() == typeof(short)) && Id.ToString() != "0"))
            {
                ViewBag.IsNew     = false;
                ViewBag.Operation = "Update";
                if (!_tokenManager.GenerateToken())
                {
                    return(Json(null, JsonRequestBehavior.AllowGet));
                }
                _ISpartan_WorkFlow_ConditionApiConsumer.SetAuthHeader(_tokenManager.Token);
                var Spartan_WorkFlow_ConditionData = _ISpartan_WorkFlow_ConditionApiConsumer.GetByKeyComplete(Id).Resource.Spartan_WorkFlow_Conditions[0];
                if (Spartan_WorkFlow_ConditionData == null)
                {
                    return(HttpNotFound());
                }

                varSpartan_WorkFlow_Condition = new Spartan_WorkFlow_ConditionModel
                {
                    ConditionId   = (short)Spartan_WorkFlow_ConditionData.ConditionId
                    , Description = Spartan_WorkFlow_ConditionData.Description
                };
            }
            if (!_tokenManager.GenerateToken())
            {
                return(Json(null, JsonRequestBehavior.AllowGet));
            }



            ViewBag.Consult = consult == 1;
            if (consult == 1)
            {
                ViewBag.Operation = "Consult";
            }
            return(View(varSpartan_WorkFlow_Condition));
        }
        public ActionResult AddSpartan_WorkFlow_Condition(int rowIndex = 0, int functionMode = 0, string id = "0")
        {
            ViewBag.currentRowIndex = rowIndex;
            ViewBag.functionMode    = functionMode;
            ViewBag.Consult         = false;
            var permission = PermissionHelper.GetRoleObjectPermission(SessionHelper.Role, 130);

            ViewBag.Permission = permission;
            if (!_tokenManager.GenerateToken())
            {
                return(null);
            }
            _ISpartan_WorkFlow_ConditionApiConsumer.SetAuthHeader(_tokenManager.Token);
            Spartan_WorkFlow_ConditionModel varSpartan_WorkFlow_Condition = new Spartan_WorkFlow_ConditionModel();


            if (id.ToString() != "0")
            {
                var Spartan_WorkFlow_ConditionsData = _ISpartan_WorkFlow_ConditionApiConsumer.ListaSelAll(0, 1000, "ConditionId=" + id, "").Resource.Spartan_WorkFlow_Conditions;

                if (Spartan_WorkFlow_ConditionsData != null && Spartan_WorkFlow_ConditionsData.Count > 0)
                {
                    var Spartan_WorkFlow_ConditionData = Spartan_WorkFlow_ConditionsData.First();
                    varSpartan_WorkFlow_Condition = new Spartan_WorkFlow_ConditionModel
                    {
                        ConditionId   = Spartan_WorkFlow_ConditionData.ConditionId
                        , Description = Spartan_WorkFlow_ConditionData.Description
                    };
                }
            }
            if (!_tokenManager.GenerateToken())
            {
                return(Json(null, JsonRequestBehavior.AllowGet));
            }



            return(PartialView("AddSpartan_WorkFlow_Condition", varSpartan_WorkFlow_Condition));
        }