Пример #1
0
        public ActionResult Post(bool IsNew, Spartan_BR_ComplexityModel varSpartan_BR_Complexity)
        {
            try
            {
                //if (ModelState.IsValid)
                //{
                if (!_tokenManager.GenerateToken())
                {
                    return(Json(null, JsonRequestBehavior.AllowGet));
                }
                _ISpartan_BR_ComplexityApiConsumer.SetAuthHeader(_tokenManager.Token);



                var result = "";
                var Spartan_BR_ComplexityInfo = new Spartan_BR_Complexity
                {
                    Key_Complexity = varSpartan_BR_Complexity.Key_Complexity
                    , Description  = varSpartan_BR_Complexity.Description
                };

                result = !IsNew?
                         _ISpartan_BR_ComplexityApiConsumer.Update(Spartan_BR_ComplexityInfo, null, null).Resource.ToString() :
                             _ISpartan_BR_ComplexityApiConsumer.Insert(Spartan_BR_ComplexityInfo, 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));
            }
        }
Пример #2
0
        public ActionResult AddSpartan_BR_Complexity(int rowIndex = 0, int functionMode = 0, string id = "0")
        {
            int ModuleId = (Session["CurrentModuleId"] != null) ? Convert.ToInt32(Session["CurrentModuleId"]) : 0;

            ViewBag.currentRowIndex = rowIndex;
            ViewBag.functionMode    = functionMode;
            ViewBag.Consult         = false;
            var permission = PermissionHelper.GetRoleObjectPermission(SessionHelper.Role, 35350);

            ViewBag.Permission = permission;
            if (!_tokenManager.GenerateToken())
            {
                return(null);
            }
            _ISpartan_BR_ComplexityApiConsumer.SetAuthHeader(_tokenManager.Token);
            Spartan_BR_ComplexityModel varSpartan_BR_Complexity = new Spartan_BR_ComplexityModel();


            if (id.ToString() != "0")
            {
                var Spartan_BR_ComplexitysData = _ISpartan_BR_ComplexityApiConsumer.ListaSelAll(0, 1000, "Key_Complexity=" + id, "").Resource.Spartan_BR_Complexitys;

                if (Spartan_BR_ComplexitysData != null && Spartan_BR_ComplexitysData.Count > 0)
                {
                    var Spartan_BR_ComplexityData = Spartan_BR_ComplexitysData.First();
                    varSpartan_BR_Complexity = new Spartan_BR_ComplexityModel
                    {
                        Key_Complexity = Spartan_BR_ComplexityData.Key_Complexity
                        , Description  = Spartan_BR_ComplexityData.Description
                    };
                }
            }
            if (!_tokenManager.GenerateToken())
            {
                return(Json(null, JsonRequestBehavior.AllowGet));
            }



            return(PartialView("AddSpartan_BR_Complexity", varSpartan_BR_Complexity));
        }
Пример #3
0
        public ActionResult Create(int Id = 0, int consult = 0, int ModuleId = 0)
        {
            if (ModuleId == 0)
            {
                ModuleId = (Session["CurrentModuleId"] != null) ? Convert.ToInt32(Session["CurrentModuleId"]) : 0;
            }
            else
            {
                Session["CurrentModuleId"] = ModuleId;
            }
            var permission = PermissionHelper.GetRoleObjectPermission(SessionHelper.Role, 35350, ModuleId);

            if ((!permission.New && Id.ToString() == "0") || (!permission.Edit && Id.ToString() != "0" && (!permission.Consult && consult == 1)))
            {
                Response.Redirect("~/");
            }
            ViewBag.Permission = permission;
            var varSpartan_BR_Complexity = new Spartan_BR_ComplexityModel();

            ViewBag.ObjectId  = "35350";
            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_BR_ComplexityApiConsumer.SetAuthHeader(_tokenManager.Token);
                var Spartan_BR_ComplexityData = _ISpartan_BR_ComplexityApiConsumer.GetByKeyComplete(Id).Resource.Spartan_BR_Complexitys[0];
                if (Spartan_BR_ComplexityData == null)
                {
                    return(HttpNotFound());
                }

                varSpartan_BR_Complexity = new Spartan_BR_ComplexityModel
                {
                    Key_Complexity = (int)Spartan_BR_ComplexityData.Key_Complexity
                    , Description  = Spartan_BR_ComplexityData.Description
                };
            }
            if (!_tokenManager.GenerateToken())
            {
                return(Json(null, JsonRequestBehavior.AllowGet));
            }



            ViewBag.Consult = consult == 1;
            if (consult == 1)
            {
                ViewBag.Operation = "Consult";
            }
            return(View(varSpartan_BR_Complexity));
        }