Example #1
0
        public ActionResult Post(bool IsNew, Adicciones_Probable_ResponsableModel varAdicciones_Probable_Responsable)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    if (!_tokenManager.GenerateToken())
                    {
                        return(Json(null, JsonRequestBehavior.AllowGet));
                    }
                    _IAdicciones_Probable_ResponsableApiConsumer.SetAuthHeader(_tokenManager.Token);



                    var result = "";
                    var Adicciones_Probable_ResponsableInfo = new Adicciones_Probable_Responsable
                    {
                        Clave         = varAdicciones_Probable_Responsable.Clave
                        , Descripcion = varAdicciones_Probable_Responsable.Descripcion
                    };

                    result = !IsNew?
                             _IAdicciones_Probable_ResponsableApiConsumer.Update(Adicciones_Probable_ResponsableInfo, null, null).Resource.ToString() :
                                 _IAdicciones_Probable_ResponsableApiConsumer.Insert(Adicciones_Probable_ResponsableInfo, null, null).Resource.ToString();

                    return(Json(result, JsonRequestBehavior.AllowGet));
                }
                return(Json(false, JsonRequestBehavior.AllowGet));
            }
            catch (ServiceException ex)
            {
                return(Json(false, JsonRequestBehavior.AllowGet));
            }
        }
Example #2
0
        public ActionResult AddAdicciones_Probable_Responsable(int rowIndex = 0, int functionMode = 0, int 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, 45313);

            ViewBag.Permission = permission;
            if (!_tokenManager.GenerateToken())
            {
                return(null);
            }
            _IAdicciones_Probable_ResponsableApiConsumer.SetAuthHeader(_tokenManager.Token);
            Adicciones_Probable_ResponsableModel varAdicciones_Probable_Responsable = new Adicciones_Probable_ResponsableModel();


            if (id.ToString() != "0")
            {
                var Adicciones_Probable_ResponsablesData = _IAdicciones_Probable_ResponsableApiConsumer.ListaSelAll(0, 1000, "Adicciones_Probable_Responsable.Clave=" + id, "").Resource.Adicciones_Probable_Responsables;

                if (Adicciones_Probable_ResponsablesData != null && Adicciones_Probable_ResponsablesData.Count > 0)
                {
                    var Adicciones_Probable_ResponsableData = Adicciones_Probable_ResponsablesData.First();
                    varAdicciones_Probable_Responsable = new Adicciones_Probable_ResponsableModel
                    {
                        Clave                    = Adicciones_Probable_ResponsableData.Clave
                        , Descripcion            = Adicciones_Probable_ResponsableData.Descripcion
                        , DescripcionDescripcion = CultureHelper.GetTraduction(Convert.ToString(Adicciones_Probable_ResponsableData.Descripcion), "Adicciones") ?? (string)Adicciones_Probable_ResponsableData.Descripcion_Adicciones.Descripcion
                    };
                }
            }
            if (!_tokenManager.GenerateToken())
            {
                return(Json(null, JsonRequestBehavior.AllowGet));
            }

            _IAdiccionesApiConsumer.SetAuthHeader(_tokenManager.Token);
            var Adiccioness_Descripcion = _IAdiccionesApiConsumer.SelAll(true);

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


            return(PartialView("AddAdicciones_Probable_Responsable", varAdicciones_Probable_Responsable));
        }
Example #3
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, 45313);

            ViewBag.Permission = permission;
            var varAdicciones_Probable_Responsable = new Adicciones_Probable_ResponsableModel();

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

                varAdicciones_Probable_Responsable = new Adicciones_Probable_ResponsableModel
                {
                    Clave                    = (int)Adicciones_Probable_ResponsableData.Clave
                    , Descripcion            = Adicciones_Probable_ResponsableData.Descripcion
                    , DescripcionDescripcion = CultureHelper.GetTraduction(Convert.ToString(Adicciones_Probable_ResponsableData.Descripcion), "Adicciones") ?? (string)Adicciones_Probable_ResponsableData.Descripcion_Adicciones.Descripcion
                };
            }
            if (!_tokenManager.GenerateToken())
            {
                return(Json(null, JsonRequestBehavior.AllowGet));
            }

            _IAdiccionesApiConsumer.SetAuthHeader(_tokenManager.Token);
            var Adiccioness_Descripcion = _IAdiccionesApiConsumer.SelAll(true);

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


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