Пример #1
0
        public JsonResult UpdateRol(int rolId, string Descripcion)
        {
            string Msj = "-1";
            IEnumerable <Object> Rol = null;

            if (db.tbRol.Any(a => a.rol_Descripcion == Descripcion && a.rol_Id != rolId))
            {
                ModelState.AddModelError("", "Ya existe un rol con el mismo nombre");
                Msj = "-2";
            }
            else
            {
                try
                {
                    if (Descripcion != null)
                    {
                        Rol = db.UDP_Acce_tbRol_Update(rolId, Descripcion, Function.GetUser(), Function.DatetimeNow());
                        foreach (UDP_Acce_tbRol_Update_Result item in Rol)
                        {
                            Msj = Convert.ToString(item.MensajeError);
                            if (Msj.StartsWith("-1"))
                            {
                                Function.InsertBitacoraErrores("Rol/Edit", Msj, "Edit");
                            }
                            else
                            {
                                Msj = "1";
                            }
                        }
                    }
                }
                catch (Exception Ex)
                {
                    Function.InsertBitacoraErrores("Rol/Edit", Ex.Message.ToString(), "Edit");
                    Msj = "-1";
                }
            }
            return(Json(Msj, JsonRequestBehavior.AllowGet));
        }