Esempio n. 1
0
        public Permiso Detalles(int id)
        {
            Permiso result = null;

            try
            {
                string nombreCache = string.Format("Permiso{0}", id);

                if (!CacheData.Exist(nombreCache))
                {
                    PermisoDAL model = new PermisoDAL(_connectionString);

                    var permiso = model.Detalles(id);

                    result = Converter.ConvertToBL(permiso);

                    CacheData.Add(nombreCache, result);
                }
                else
                {
                    result = (Permiso)CacheData.Get(nombreCache);
                }
            }
            catch (Exception ex)
            {
                log.Error("Detalles()", ex);
            }

            return(result);
        }
Esempio n. 2
0
        public bool Modificar(Permiso permiso)
        {
            bool updated = false;

            try
            {
                DAL.DTO.Permiso permisoDal = Converter.ConvertToDAL(permiso);

                PermisoDAL mod = new PermisoDAL(_connectionString);

                updated = mod.Modificar(permisoDal);


                if (updated)
                {
                    // Si había una caché para prensa la borramos
                    string nombreCache = string.Format("permiso{0}", permiso.tipoPermiso);
                    CacheData.Remove(nombreCache);
                }
            }
            catch (Exception er)
            {
                log.Error("Agregar()", er);
            }

            return(updated);
        }
Esempio n. 3
0
        public static void Borrar(PermisoBE permiso)
        {
            PermisoDAL.Guardar(permiso, false, false);

            // Guardo la bitácora
            Bitacora.Loguear("Se eliminó el permiso con Id " + permiso.Id);
        }
Esempio n. 4
0
        public Permiso GetByID(int ID)
        {
            Permiso result     = default(Permiso);
            var     PermisoDAL = new PermisoDAL();

            result = PermisoDAL.ReadBy(ID);
            return(result);
        }
Esempio n. 5
0
        public Permiso Create(Permiso Permiso)
        {
            Permiso result     = default(Permiso);
            var     PermisoDAL = new PermisoDAL();

            result = PermisoDAL.Create(Permiso);
            return(result);
        }
Esempio n. 6
0
        public List <Permiso> ListarTodos()
        {
            List <Permiso> result = default(List <Permiso>);

            var PermisoDAL = new PermisoDAL();

            result = PermisoDAL.Read();
            return(result);
        }
Esempio n. 7
0
        public static void Guardar(PermisoBE permiso)
        {
            PermisoDAL.Guardar(permiso, true, true);

            // Guardo la bitácora
            string mensajeBitacora = permiso.Id > 0 ? "Se actualizó el permiso con Id " + permiso.Id :
                                     "Se creó un nuevo permiso. Nombre: " + permiso.Nombre;

            Bitacora.Loguear(mensajeBitacora);
        }
Esempio n. 8
0
        public void Remover(Familia familia, Permiso hijo)
        {
            using (IUnitOfWork unitOfWork = UnitOfWorkFactory.Create())
            {
                PermisoDAL permisoDAL = new PermisoDAL(unitOfWork);
                permisoDAL.Remover(familia, hijo);
                unitOfWork.SaveChanges();

                familia.Remover(hijo);
            }
        }
Esempio n. 9
0
        public bool Eliminar(Permiso Permiso)
        {
            var PermisoDAL = new PermisoDAL();

            try
            {
                PermisoDAL.Eliminar(Permiso);
                return(true);
            }
            catch
            {
                Console.WriteLine("Error al eliminar el elemento");
                return(false);
            }
        }
Esempio n. 10
0
        public bool Edit(Permiso Permiso)
        {
            var PermisoDAL = new PermisoDAL();

            try
            {
                PermisoDAL.Update(Permiso);
                return(true);
            }
            catch
            {
                Console.WriteLine("Error al editar el elemento");
                return(false);
            }
        }
Esempio n. 11
0
        public bool Delete(int ID)
        {
            var PermisoDAL = new PermisoDAL();

            try
            {
                PermisoDAL.Delete(ID);
                return(true);
            }
            catch
            {
                Console.WriteLine("Error al eliminar el elemento");
                return(false);
            }
        }
Esempio n. 12
0
        public void Agregar(Familia familia, Permiso hijo)
        {
            if (familia.Buscar(hijo))
            {
                throw new InvalidOperationException("El permiso que desea agregar ya existe");
            }

            if (hijo.Buscar(familia))
            {
                throw new InvalidCastException("No puede crear dependencias circulares");
            }

            familia.Agregar(hijo);

            using (IUnitOfWork unitOfWork = UnitOfWorkFactory.Create())
            {
                PermisoDAL permisoDAL = new PermisoDAL(unitOfWork);
                permisoDAL.Agregar(familia, hijo);
                unitOfWork.SaveChanges();
            }
        }
Esempio n. 13
0
        public List <Permiso> Listar()
        {
            List <Permiso> result = null;

            try
            {
                PermisoDAL model    = new PermisoDAL(_connectionString);
                var        permisos = model.Listar();

                if (permisos != null)
                {
                    result = Converter.ConvertToBL(permisos);
                }
            }
            catch (Exception ex)
            {
                log.Error("Listar()", ex);
            }

            return(result);
        }
Esempio n. 14
0
        public bool Eliminar(int Id_Permiso)
        {
            bool sw = false;

            try
            {
                PermisoDAL model = new PermisoDAL(_connectionString);
                sw = model.Eliminar(Id_Permiso);

                if (sw)
                {
                    // Si había una caché para prensa la borramos
                    string nombreCache = string.Format("permiso{0}", Id_Permiso);
                    CacheData.Remove(nombreCache);
                }
            }
            catch (Exception er)
            {
                log.Error("Eliminar(Id_Permiso: {0})", er, Id_Permiso);
            }
            return(sw);
        }
Esempio n. 15
0
 public static List <PermisoBE> ObtenerPerfiles()
 {
     return(PermisoDAL.ObtenerPerfiles());
 }
Esempio n. 16
0
 public Permiso()
 {
     _mapeador = new PermisoDAL();
 }
Esempio n. 17
0
 public PermisoBLL()
 {
     this._dao        = new PermisoDAL();
     this._daoFamilia = new FamiliaPermisoDAL();
 }
Esempio n. 18
0
 public PermisoBLL(PermisoDAL pDAO, IFamiliaPermisoDAL pFamiliaDAO)
 {
     this._dao        = pDAO;
     this._daoFamilia = pFamiliaDAO;
 }