Exemple #1
0
        public ActionResult Create(int Id = 0, int consult = 0)
        {
            int ModuleId   = (Session["CurrentModuleId"] != null) ? Convert.ToInt32(Session["CurrentModuleId"]) : 0;
            var permission = PermissionHelper.GetRoleObjectPermission(SessionHelper.Role, 127);

            ViewBag.Permission = permission;
            var varSpartan_WorkFlow_State = new Spartan_WorkFlow_StateModel();

            ViewBag.ObjectId  = "127";
            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_StateApiConsumer.SetAuthHeader(_tokenManager.Token);
                var Spartan_WorkFlow_StateData = _ISpartan_WorkFlow_StateApiConsumer.GetByKeyComplete(Id).Resource.Spartan_WorkFlow_States[0];
                if (Spartan_WorkFlow_StateData == null)
                {
                    return(HttpNotFound());
                }

                varSpartan_WorkFlow_State = new Spartan_WorkFlow_StateModel
                {
                    StateId                 = (int)Spartan_WorkFlow_StateData.StateId
                    , Phase                 = Spartan_WorkFlow_StateData.Phase
                    , PhaseName             = (string)Spartan_WorkFlow_StateData.Phase_Spartan_WorkFlow_Phases.Name
                    , Attribute             = Spartan_WorkFlow_StateData.Attribute
                    , AttributeLogical_Name = (string)Spartan_WorkFlow_StateData.Attribute_Spartan_Metadata.Logical_Name
                    , State_Code            = Spartan_WorkFlow_StateData.State_Code
                    , Name  = Spartan_WorkFlow_StateData.Name
                    , Value = Spartan_WorkFlow_StateData.Value
                    , Text  = Spartan_WorkFlow_StateData.Text
                };
            }
            if (!_tokenManager.GenerateToken())
            {
                return(Json(null, JsonRequestBehavior.AllowGet));
            }

            _ISpartan_WorkFlow_PhasesApiConsumer.SetAuthHeader(_tokenManager.Token);
            var Spartan_WorkFlow_Phasess_Phase = _ISpartan_WorkFlow_PhasesApiConsumer.SelAll(true);

            if (Spartan_WorkFlow_Phasess_Phase != null && Spartan_WorkFlow_Phasess_Phase.Resource != null)
            {
                ViewBag.Spartan_WorkFlow_Phasess_Phase = Spartan_WorkFlow_Phasess_Phase.Resource.OrderBy(m => m.Name).Select(m => new SelectListItem
                {
                    Text = m.Name.ToString(), Value = Convert.ToString(m.PhasesId)
                }).ToList();
            }
            _ISpartan_MetadataApiConsumer.SetAuthHeader(_tokenManager.Token);
            var Spartan_Metadatas_Attribute = _ISpartan_MetadataApiConsumer.SelAll(true);

            if (Spartan_Metadatas_Attribute != null && Spartan_Metadatas_Attribute.Resource != null)
            {
                ViewBag.Spartan_Metadatas_Attribute = Spartan_Metadatas_Attribute.Resource.OrderBy(m => m.Logical_Name).Select(m => new SelectListItem
                {
                    Text = m.Logical_Name.ToString(), Value = Convert.ToString(m.AttributeId)
                }).ToList();
            }


            ViewBag.Consult = consult == 1;
            if (consult == 1)
            {
                ViewBag.Operation = "Consult";
            }
            return(View(varSpartan_WorkFlow_State));
        }
        public ActionResult Create(int Id = 0, int consult = 0)
        {
            int ModuleId   = (Session["CurrentModuleId"] != null) ? Convert.ToInt32(Session["CurrentModuleId"]) : 0;
            var permission = PermissionHelper.GetRoleObjectPermission(SessionHelper.Role, 133);

            ViewBag.Permission = permission;
            var varSpartan_WorkFlow_Roles_by_State = new Spartan_WorkFlow_Roles_by_StateModel();

            ViewBag.ObjectId  = "133";
            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_Roles_by_StateApiConsumer.SetAuthHeader(_tokenManager.Token);
                var Spartan_WorkFlow_Roles_by_StateData = _ISpartan_WorkFlow_Roles_by_StateApiConsumer.GetByKeyComplete(Id).Resource.Spartan_WorkFlow_Roles_by_States[0];
                if (Spartan_WorkFlow_Roles_by_StateData == null)
                {
                    return(HttpNotFound());
                }

                varSpartan_WorkFlow_Roles_by_State = new Spartan_WorkFlow_Roles_by_StateModel
                {
                    Roles_by_StateId        = (int)Spartan_WorkFlow_Roles_by_StateData.Roles_by_StateId
                    , Phase                 = Spartan_WorkFlow_Roles_by_StateData.Phase
                    , PhaseName             = (string)Spartan_WorkFlow_Roles_by_StateData.Phase_Spartan_WorkFlow_Phases.Name
                    , State                 = Spartan_WorkFlow_Roles_by_StateData.State
                    , StateName             = (string)Spartan_WorkFlow_Roles_by_StateData.State_Spartan_WorkFlow_State.Name
                    , User_Role             = Spartan_WorkFlow_Roles_by_StateData.User_Role
                    , Phase_Transition      = Spartan_WorkFlow_Roles_by_StateData.Phase_Transition
                    , Permission_To_Consult = Spartan_WorkFlow_Roles_by_StateData.Permission_To_Consult.GetValueOrDefault()
                    , Permission_To_New     = Spartan_WorkFlow_Roles_by_StateData.Permission_To_New.GetValueOrDefault()
                    , Permission_To_Modify  = Spartan_WorkFlow_Roles_by_StateData.Permission_To_Modify.GetValueOrDefault()
                    , Permission_to_Delete  = Spartan_WorkFlow_Roles_by_StateData.Permission_to_Delete.GetValueOrDefault()
                    , Permission_To_Export  = Spartan_WorkFlow_Roles_by_StateData.Permission_To_Export.GetValueOrDefault()
                    , Permission_To_Print   = Spartan_WorkFlow_Roles_by_StateData.Permission_To_Print.GetValueOrDefault()
                    , Permission_Settings   = Spartan_WorkFlow_Roles_by_StateData.Permission_Settings.GetValueOrDefault()
                };
            }
            if (!_tokenManager.GenerateToken())
            {
                return(Json(null, JsonRequestBehavior.AllowGet));
            }

            _ISpartan_WorkFlow_PhasesApiConsumer.SetAuthHeader(_tokenManager.Token);
            var Spartan_WorkFlow_Phasess_Phase = _ISpartan_WorkFlow_PhasesApiConsumer.SelAll(true);

            if (Spartan_WorkFlow_Phasess_Phase != null && Spartan_WorkFlow_Phasess_Phase.Resource != null)
            {
                ViewBag.Spartan_WorkFlow_Phasess_Phase = Spartan_WorkFlow_Phasess_Phase.Resource.OrderBy(m => m.Name).Select(m => new SelectListItem
                {
                    Text = m.Name.ToString(), Value = Convert.ToString(m.PhasesId)
                }).ToList();
            }
            _ISpartan_WorkFlow_StateApiConsumer.SetAuthHeader(_tokenManager.Token);
            var Spartan_WorkFlow_States_State = _ISpartan_WorkFlow_StateApiConsumer.SelAll(true);

            if (Spartan_WorkFlow_States_State != null && Spartan_WorkFlow_States_State.Resource != null)
            {
                ViewBag.Spartan_WorkFlow_States_State = Spartan_WorkFlow_States_State.Resource.OrderBy(m => m.Name).Select(m => new SelectListItem
                {
                    Text = m.Name.ToString(), Value = Convert.ToString(m.StateId)
                }).ToList();
            }


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