示例#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, 45100);

            ViewBag.Permission = permission;
            var varDetalle_de_Requerido_en_Comparecencia = new Detalle_de_Requerido_en_ComparecenciaModel();

            ViewBag.ObjectId  = "45100";
            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));
                }
                _IDetalle_de_Requerido_en_ComparecenciaApiConsumer.SetAuthHeader(_tokenManager.Token);
                var Detalle_de_Requerido_en_ComparecenciaData = _IDetalle_de_Requerido_en_ComparecenciaApiConsumer.GetByKeyComplete(Id).Resource.Detalle_de_Requerido_en_Comparecencias[0];
                if (Detalle_de_Requerido_en_ComparecenciaData == null)
                {
                    return(HttpNotFound());
                }

                varDetalle_de_Requerido_en_Comparecencia = new Detalle_de_Requerido_en_ComparecenciaModel
                {
                    Clave          = (int)Detalle_de_Requerido_en_ComparecenciaData.Clave
                    , Nombre       = Detalle_de_Requerido_en_ComparecenciaData.Nombre
                    , NombreNombre = CultureHelper.GetTraduction(Convert.ToString(Detalle_de_Requerido_en_ComparecenciaData.Nombre), "Requerido") ?? (string)Detalle_de_Requerido_en_ComparecenciaData.Nombre_Requerido.Nombre
                };
            }
            if (!_tokenManager.GenerateToken())
            {
                return(Json(null, JsonRequestBehavior.AllowGet));
            }

            _IRequeridoApiConsumer.SetAuthHeader(_tokenManager.Token);
            var Requeridos_Nombre = _IRequeridoApiConsumer.SelAll(true);

            if (Requeridos_Nombre != null && Requeridos_Nombre.Resource != null)
            {
                ViewBag.Requeridos_Nombre = Requeridos_Nombre.Resource.Where(m => m.Nombre != null).OrderBy(m => m.Nombre).Select(m => new SelectListItem
                {
                    Text = CultureHelper.GetTraduction(Convert.ToString(m.Clave), "Requerido", "Nombre") ?? m.Nombre.ToString(), Value = Convert.ToString(m.Clave)
                }).ToList();
            }


            ViewBag.Consult = consult == 1;
            if (consult == 1)
            {
                ViewBag.Operation = "Consult";
            }
            return(View(varDetalle_de_Requerido_en_Comparecencia));
        }
示例#2
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, 45116, ModuleId);

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

            varRequerido.Clave = Id;

            ViewBag.ObjectId  = "45116";
            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";

                _tokenManager.GenerateToken();
                _ISpartane_FileApiConsumer.SetAuthHeader(_tokenManager.Token);
                _IRequeridoApiConsumer.SetAuthHeader(_tokenManager.Token);
                var RequeridosData = _IRequeridoApiConsumer.ListaSelAll(0, 1000, "Requerido.Clave=" + Id, "").Resource.Requeridos;

                if (RequeridosData != null && RequeridosData.Count > 0)
                {
                    var RequeridoData = RequeridosData.First();
                    varRequerido = new RequeridoModel
                    {
                        Clave       = RequeridoData.Clave
                        , Nombre    = RequeridoData.Nombre
                        , Solicitud = RequeridoData.Solicitud
                    };
                }
            }
            if (!_tokenManager.GenerateToken())
            {
                return(Json(null, JsonRequestBehavior.AllowGet));
            }



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

            var viewInEframe  = false;
            var isPartial     = false;
            var isMR          = false;
            var nameMR        = string.Empty;
            var nameAttribute = string.Empty;

            if (Request.QueryString["isPartial"] != null)
            {
                isPartial = Convert.ToBoolean(Request.QueryString["isPartial"]);
            }

            if (Request.QueryString["isMR"] != null)
            {
                isMR = Convert.ToBoolean(Request.QueryString["isMR"]);
            }

            if (Request.QueryString["nameMR"] != null)
            {
                nameMR = Request.QueryString["nameMR"].ToString();
            }

            if (Request.QueryString["nameAttribute"] != null)
            {
                nameAttribute = Request.QueryString["nameAttribute"].ToString();
            }

            if (Request.QueryString["viewInEframe"] != null)
            {
                viewInEframe = Convert.ToBoolean(Request.QueryString["viewInEframe"]);
            }

            ViewBag.isPartial     = isPartial;
            ViewBag.isMR          = isMR;
            ViewBag.nameMR        = nameMR;
            ViewBag.nameAttribute = nameAttribute;
            ViewBag.viewInEframe  = viewInEframe;


            return(View(varRequerido));
        }