Beispiel #1
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="context"></param>
 /// <param name="logger"></param>
 /// <param name="localizer"></param>
 public BaseController(CaducaContext context, ILogger <BaseController> logger, LocService localizer)
 {
     this._context   = context;
     this._localizer = localizer;
     this.logger     = logger;
     permiso         = new PermisoDTO();
 }
Beispiel #2
0
        public ActionResult EditPermiso(PermisoDTO param)
        {
            try
            {
                //-----------------------------------------------------------------------------------------------
                var    ctx = new SOLPEREntities();
                var    p   = param.GetPermiso();
                string msg;
                //-----------------------------------------------------------------------------------------------
                if (param.EsNuevo())
                {
                    ctx.PERMISOS.Add(p);
                    msg = "Solicitud de permiso añadido exitosamente.";
                }
                else
                {
                    ctx.PERMISOS.Attach(p);
                    ctx.Entry(p).State = EntityState.Modified;
                    msg = "Solicitud de permiso actualizada exitosamente.";
                }
                //-----------------------------------------------------------------------------------------------
                ctx.SaveChanges();
                //-----------------------------------------------------------------------------------------------

                return(Json(new { Code = 1, Mensaje = msg }, "txt/json", JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                return(Json(new { Code = 3, Mensaje = ex.Message }, "txt/json", JsonRequestBehavior.AllowGet));
            }
        }
Beispiel #3
0
        public async Task <IActionResult> Create(PermisoDTO dto)
        {
            try
            {
                var entity = await _permisoService.Insert(dto, Usuario);

                return(Ok(entity));
            }
            catch (Exception e)
            {
                return(StatusCode(500, e.Message));
            }
        }
Beispiel #4
0
        protected void btnAsignar_Click(object sender, EventArgs e)
        {
            int        cont          = 0;
            PermisoDTO thePermisoDTO = new PermisoDTO();

            foreach (RepeaterItem item in rptGrupo.Items)
            {
                if (cont == 0)
                {
                    thePermisoDTO.Usuario = hidRut.Value;
                    YouCom.Seguridad.BLL.PermisoBLL.Delete(thePermisoDTO);
                    cont++;
                }

                HiddenField hdnGrupoCod = new HiddenField();
                hdnGrupoCod = (HiddenField)item.FindControl("hdnFuncionGrupoCod");

                Repeater rptFunciones = new Repeater();
                rptFunciones = (Repeater)item.FindControl("rptFuncionesGrupo");

                foreach (RepeaterItem itemFunciones in rptFunciones.Items)
                {
                    CheckBox funcion = new CheckBox();
                    funcion = (CheckBox)itemFunciones.FindControl("chkFuncion");

                    if (funcion.Checked)
                    {
                        HiddenField hdnFuncion = new HiddenField();
                        hdnFuncion = (HiddenField)itemFunciones.FindControl("hdnFuncionGrupoCod");

                        ///Graba Permisos Generales de Acceso a las paginas

                        thePermisoDTO.Funcion = hdnFuncion.Value;
                        thePermisoDTO.Empresa = this.txtRut.Text;
                        thePermisoDTO.Usuario = hidRut.Value;

                        //elimina permisos existentes
                        //vuelve a crear permisos existentes
                        YouCom.Seguridad.BLL.PermisoBLL.Insert(thePermisoDTO);


                        if (!Page.ClientScript.IsClientScriptBlockRegistered("SET"))
                        {
                            string script = "alert('Permisos Asociados Exitosamente.');";
                            Page.ClientScript.RegisterStartupScript(this.GetType(), "SET", script, true);
                        }
                    }
                }
            }
        }
Beispiel #5
0
        public async Task <IActionResult> Update(int id, PermisoDTO dto)
        {
            try
            {
                var entity = await _permisoService.Update(dto, id, Usuario);

                return(Ok(entity));
            }
            catch (NotFoundException nf) { return(NotFound(nf.Message)); }
            catch (Exception e)
            {
                return(StatusCode(500, e.Message));
            }
        }
Beispiel #6
0
        public async Task <PermisoDTO> Insert(PermisoDTO dto, UsuarioDTO currUser)
        {
            var entity = _mapper.Map <Permiso>(dto);

            entity.UpdateDate               = entity.CreationDate = DateTime.Now;
            entity.UpdateUserId             = entity.CreationUserId = currUser.Id;
            entity.Active                   = true;
            entity.IsSuperUser              = false;
            entity.PermisoControladorAccion = dto.ControllersIds.Select(s => new PermisoControladorAccion {
                ControladorId = s, Permiso = entity
            }).ToList();
            entity = await _permisoRepository.Insert(entity);

            return(_mapper.Map <PermisoDTO>(entity));
        }
Beispiel #7
0
        public ActionResult GetPermiso(long id)
        {
            try
            {
                var ctx     = new SOLPEREntities();
                var p       = ctx.PERMISOS.FirstOrDefault(u => u.Id == id);
                var permiso = new PermisoDTO(p);

                return(Json(new { Code = 1, Permiso = permiso }, "txt/json", JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                return(Json(new { Code = 3, Mensaje = ex.Message }, "txt/json", JsonRequestBehavior.AllowGet));
            }
        }
Beispiel #8
0
        public async Task <PermisoDTO> Update(PermisoDTO dto, int id, UsuarioDTO currUser)
        {
            var entity = await _permisoRepository.GetBy(s => s.Id == id, s => s.PermisoControladorAccion);

            if (entity == null)
            {
                throw new NotFoundException();
            }
            await _permisoControladorRepository.RemoveRange(entity.PermisoControladorAccion);

            entity.UpdateDate               = DateTime.Now;
            entity.UpdateUserId             = currUser.Id;
            entity.PermisoControladorAccion = dto.ControllersIds.Select(s => new PermisoControladorAccion {
                ControladorId = s, Permiso = entity
            }).ToList();
            entity = await _permisoRepository.Update(entity);

            return(_mapper.Map <PermisoDTO>(entity));
        }
Beispiel #9
0
        public static void DeletePermisos(PermisoDTO thePermisoDTO)
        {
            SqlConnection myConnection = IMDB.GetConnection();
            SqlCommand    myCommand    = new SqlCommand("DEL_Permisos", myConnection);

            myCommand.CommandType = CommandType.StoredProcedure;

            myCommand.Parameters.Add("@usuario", SqlDbType.Int).Value = thePermisoDTO.Usuario;

            try
            {
                myConnection.Open();
                myCommand.ExecuteNonQuery();
            }
            catch (SqlException ex)
            {
                throw new Exception(ex.Message);
            }
        }
Beispiel #10
0
        /// <summary>
        /// Inserta los permisos para las funcionalidades al Usuario asignado
        /// </summary>
        public static void InsertaPermisos(PermisoDTO thePermisoDTO)
        {
            SqlConnection myConnection = IMDB.GetConnection();
            SqlCommand    myCommand    = new SqlCommand("INS_Permiso", myConnection);

            myCommand.CommandType = CommandType.StoredProcedure;

            myCommand.Parameters.Add("@pGrupoCod", SqlDbType.VarChar).Value   = thePermisoDTO.Empresa;
            myCommand.Parameters.Add("@pRolCod", SqlDbType.VarChar).Value     = thePermisoDTO.Usuario;
            myCommand.Parameters.Add("@pFuncionCod", SqlDbType.VarChar).Value = thePermisoDTO.Funcion;

            try
            {
                myConnection.Open();
                myCommand.ExecuteNonQuery();
            }
            catch (SqlException ex)
            {
                throw new Exception(ex.Message);
            }
        }
Beispiel #11
0
 public static void DeletePermisos(PermisoDTO thePermisoDTO)
 {
     YouCom.Seguridad.DAL.Perfilamiento.DeletePermisos(thePermisoDTO);
 }
Beispiel #12
0
 public static void InsertaPermisos(PermisoDTO thePermisoDTO)
 {
     YouCom.Seguridad.DAL.Perfilamiento.InsertaPermisos(thePermisoDTO);
 }
Beispiel #13
0
        public static bool Insert(PermisoDTO thePermisoDTO)
        {
            var resultado = YouCom.Seguridad.DAL.PermisoDAL.Insert(thePermisoDTO);

            return(resultado);
        }
Beispiel #14
0
        public static bool Delete(PermisoDTO thePermisoDTO)
        {
            var resultado = YouCom.Seguridad.DAL.PermisoDAL.Delete(thePermisoDTO);

            return(resultado);
        }