Ejemplo n.º 1
0
        public ActionResult Post(bool IsNew, areas_EmpresasModel varareas_Empresas)
        {
            try
            {
                //if (ModelState.IsValid)
                //{
                if (!_tokenManager.GenerateToken())
                {
                    return(Json(null, JsonRequestBehavior.AllowGet));
                }
                _Iareas_EmpresasApiConsumer.SetAuthHeader(_tokenManager.Token);



                var result             = "";
                var areas_EmpresasInfo = new areas_Empresas
                {
                    Clave    = varareas_Empresas.Clave
                    , Nombre = varareas_Empresas.Nombre
                };

                result = !IsNew?
                         _Iareas_EmpresasApiConsumer.Update(areas_EmpresasInfo, null, null).Resource.ToString() :
                             _Iareas_EmpresasApiConsumer.Insert(areas_EmpresasInfo, 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));
            }
        }
Ejemplo n.º 2
0
        public ActionResult Addareas_Empresas(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, 44409);

            ViewBag.Permission = permission;
            if (!_tokenManager.GenerateToken())
            {
                return(null);
            }
            _Iareas_EmpresasApiConsumer.SetAuthHeader(_tokenManager.Token);
            areas_EmpresasModel varareas_Empresas = new areas_EmpresasModel();


            if (id.ToString() != "0")
            {
                var areas_EmpresassData = _Iareas_EmpresasApiConsumer.ListaSelAll(0, 1000, "areas_Empresas.Clave=" + id, "").Resource.areas_Empresass;

                if (areas_EmpresassData != null && areas_EmpresassData.Count > 0)
                {
                    var areas_EmpresasData = areas_EmpresassData.First();
                    varareas_Empresas = new areas_EmpresasModel
                    {
                        Clave    = areas_EmpresasData.Clave
                        , Nombre = areas_EmpresasData.Nombre
                    };
                }
            }
            if (!_tokenManager.GenerateToken())
            {
                return(Json(null, JsonRequestBehavior.AllowGet));
            }



            return(PartialView("Addareas_Empresas", varareas_Empresas));
        }
Ejemplo n.º 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, 44409, ModuleId);

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

            varareas_Empresas.Clave = Id;

            ViewBag.ObjectId  = "44409";
            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);
                _Iareas_EmpresasApiConsumer.SetAuthHeader(_tokenManager.Token);
                var areas_EmpresassData = _Iareas_EmpresasApiConsumer.ListaSelAll(0, 1000, "areas_Empresas.Clave=" + Id, "").Resource.areas_Empresass;

                if (areas_EmpresassData != null && areas_EmpresassData.Count > 0)
                {
                    var areas_EmpresasData = areas_EmpresassData.First();
                    varareas_Empresas = new areas_EmpresasModel
                    {
                        Clave    = areas_EmpresasData.Clave
                        , Nombre = areas_EmpresasData.Nombre
                    };
                }
            }
            if (!_tokenManager.GenerateToken())
            {
                return(Json(null, JsonRequestBehavior.AllowGet));
            }



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

            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();
            }

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


            return(View(varareas_Empresas));
        }