Exemple #1
0
        public ActionResult Create(short Id = 0, int consult = 0)
        {
            var permission = PermissionHelper.GetRoleObjectPermission(SessionHelper.Role, 50013);

            ViewBag.Permission = permission;
            var varSpartan_BR_Condition = new Spartan_BR_ConditionModel();



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

                varSpartan_BR_Condition = new Spartan_BR_ConditionModel
                {
                    ConditionId           = Spartan_BR_ConditionData.ConditionId
                    , Description         = Spartan_BR_ConditionData.Description
                    , Implementation_Code = Spartan_BR_ConditionData.Implementation_Code
                };
            }
            if (!_tokenManager.GenerateToken())
            {
                return(Json(null, JsonRequestBehavior.AllowGet));
            }



            ViewBag.Consult = consult == 1;
            return(View(varSpartan_BR_Condition));
        }
Exemple #2
0
        public ActionResult Post(Spartan_BR_ConditionModel varSpartan_BR_Condition)
        {
            try
            {
                if (!_tokenManager.GenerateToken())
                {
                    return(Json(null, JsonRequestBehavior.AllowGet));
                }
                _ISpartan_BR_ConditionApiConsumer.SetAuthHeader(_tokenManager.Token);



                var result = "0";
                var Spartan_BR_ConditionInfo = new Spartan_BR_Condition
                {
                    ConditionId           = varSpartan_BR_Condition.ConditionId
                    , Description         = varSpartan_BR_Condition.Description
                    , Implementation_Code = varSpartan_BR_Condition.Implementation_Code
                };

                result = varSpartan_BR_Condition.ConditionId.ToString() != "0" ?
                         _ISpartan_BR_ConditionApiConsumer.Update(Spartan_BR_ConditionInfo, null, null).Resource.ToString() :
                         _ISpartan_BR_ConditionApiConsumer.Insert(Spartan_BR_ConditionInfo, null, null).Resource.ToString();

                if (varSpartan_BR_Condition.ConditionId.ToString() != "0")
                {
                    result = varSpartan_BR_Condition.ConditionId.ToString();
                }

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