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

            ViewBag.Permission = permission;
            var varSpartan_Format_Field = new Spartan_Format_FieldModel();

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

            ViewBag.IsNew = true;



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

                varSpartan_Format_Field = new Spartan_Format_FieldModel
                {
                    FormatFieldId         = (int)Spartan_Format_FieldData.FormatFieldId
                    , Format              = Spartan_Format_FieldData.Format
                    , FormatFormat_Name   = (string)Spartan_Format_FieldData.Format_Spartan_Format.Format_Name
                    , Field_Path          = Spartan_Format_FieldData.Field_Path
                    , Physical_Field_Name = Spartan_Format_FieldData.Physical_Field_Name
                    , Logical_Field_Name  = Spartan_Format_FieldData.Logical_Field_Name
                    , Creation_Date       = (Spartan_Format_FieldData.Creation_Date == null ? string.Empty : Convert.ToDateTime(Spartan_Format_FieldData.Creation_Date).ToString(ConfigurationProperty.DateFormat))
                    , Creation_Hour       = Spartan_Format_FieldData.Creation_Hour
                    , Creation_User       = Spartan_Format_FieldData.Creation_User
                    , Properties          = Spartan_Format_FieldData.Properties
                };
            }
            if (!_tokenManager.GenerateToken())
            {
                return(Json(null, JsonRequestBehavior.AllowGet));
            }

            _ISpartan_FormatApiConsumer.SetAuthHeader(_tokenManager.Token);
            var Spartan_Formats = _ISpartan_FormatApiConsumer.SelAll(true);

            if (Spartan_Formats != null && Spartan_Formats.Resource != null)
            {
                ViewBag.Spartan_Formats = Spartan_Formats.Resource.Select(m => new SelectListItem
                {
                    Text = m.Format_Name.ToString(), Value = Convert.ToString(m.FormatId)
                }).ToList();
            }


            ViewBag.Consult = consult == 1;
            if (consult == 1)
            {
                ViewBag.Operation = "Consult";
            }
            return(View(varSpartan_Format_Field));
        }
        public ActionResult Create(int Id = 0, int consult = 0)
        {
            var permission = PermissionHelper.GetRoleObjectPermission(SessionHelper.Role, 31868);

            ViewBag.Permission = permission;
            var varSpartan_Format_Permissions = new Spartan_Format_PermissionsModel();

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

            ViewBag.IsNew = true;



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

                varSpartan_Format_Permissions = new Spartan_Format_PermissionsModel
                {
                    PermissionId                 = (int)Spartan_Format_PermissionsData.PermissionId
                    , Format                     = Spartan_Format_PermissionsData.Format
                    , FormatFormat_Name          = (string)Spartan_Format_PermissionsData.Format_Spartan_Format.Format_Name
                    , Permission_Type            = Spartan_Format_PermissionsData.Permission_Type
                    , Permission_TypeDescription = (string)Spartan_Format_PermissionsData.Permission_Type_Spartan_Format_Permission_Type.Description
                    , Apply             = Spartan_Format_PermissionsData.Apply.GetValueOrDefault()
                    , Spartan_User_Role = Spartan_Format_PermissionsData.Spartan_User_Role
                };
            }
            if (!_tokenManager.GenerateToken())
            {
                return(Json(null, JsonRequestBehavior.AllowGet));
            }

            _ISpartan_FormatApiConsumer.SetAuthHeader(_tokenManager.Token);
            var Spartan_Formats = _ISpartan_FormatApiConsumer.SelAll(true);

            if (Spartan_Formats != null && Spartan_Formats.Resource != null)
            {
                ViewBag.Spartan_Formats = Spartan_Formats.Resource.Select(m => new SelectListItem
                {
                    Text = m.Format_Name.ToString(), Value = Convert.ToString(m.FormatId)
                }).ToList();
            }
            _ISpartan_Format_Permission_TypeApiConsumer.SetAuthHeader(_tokenManager.Token);
            var Spartan_Format_Permission_Types = _ISpartan_Format_Permission_TypeApiConsumer.SelAll(true);

            if (Spartan_Format_Permission_Types != null && Spartan_Format_Permission_Types.Resource != null)
            {
                ViewBag.Spartan_Format_Permission_Types = Spartan_Format_Permission_Types.Resource.Select(m => new SelectListItem
                {
                    Text = m.Description.ToString(), Value = Convert.ToString(m.PermissionTypeId)
                }).ToList();
            }


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