Beispiel #1
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, 32362, ModuleId);

            if ((!permission.New && Id.ToString() == "0") || (!permission.Edit && Id.ToString() != "0" && (!permission.Consult && consult == 1)))
            {
                Response.Redirect("~/Frontal/Accounts/UnAuthorized?controllerName=Spartan_Traduction_Concept_Type&ActionName=Create");
            }
            ViewBag.Permission = permission;
            var varSpartan_Traduction_Concept_Type = new Spartan_Traduction_Concept_TypeModel();

            ViewBag.ObjectId  = "32362";
            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_Traduction_Concept_TypeApiConsumer.SetAuthHeader(_tokenManager.Token);
                var Spartan_Traduction_Concept_TypeData = _ISpartan_Traduction_Concept_TypeApiConsumer.GetByKeyComplete(Id).Resource.Spartan_Traduction_Concept_Types[0];
                if (Spartan_Traduction_Concept_TypeData == null)
                {
                    return(HttpNotFound());
                }

                varSpartan_Traduction_Concept_Type = new Spartan_Traduction_Concept_TypeModel
                {
                    IdConcept             = (int)Spartan_Traduction_Concept_TypeData.IdConcept
                    , Concept_Description = Spartan_Traduction_Concept_TypeData.Concept_Description
                };
            }
            if (!_tokenManager.GenerateToken())
            {
                return(Json(null, JsonRequestBehavior.AllowGet));
            }



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