public JsonResponse GetById(DTO.TABLAS.SEG_USUARIO.SEG_USUARIODTO usuarioDTO)
        {
            var jsonResponse = new JsonResponse {
                Success = true
            };

            try
            {
                var usuario     = MapperHelper.Map <DTO.TABLAS.SEG_USUARIO.SEG_USUARIODTO, Entidades.SEG_USUARIO.SEG_USUARIO>(usuarioDTO);
                var usuarioList = SEG_USUARIOBL.Instancia.GetById(usuario);
                if (usuarioList != null)
                {
                    var usuarioDTOList = MapperHelper.Map <IEnumerable <Entidades.SEG_USUARIO.SEG_USUARIO>, IEnumerable <DTO.TABLAS.SEG_USUARIO.SEG_USUARIODTO> >(usuarioList);
                    jsonResponse.Data = usuarioDTOList;
                }
                else
                {
                    jsonResponse.Warning = true;
                    jsonResponse.Message = Mensajes.UsuarioNoExiste;
                }
            }
            catch (Exception ex)
            {
                LogError(ex);
                jsonResponse.Success = false;
                jsonResponse.Message = Mensajes.IntenteloMasTarde;
            }

            return(jsonResponse);
        }
        public JsonResponse GetByUsername(DTO.TABLAS.SEG_USUARIO.SEG_USUARIODTO loginDTO)
        {
            var jsonResponse = new JsonResponse {
                Success = true
            };

            try
            {
                var usuario = SEG_USUARIOBL.Instancia.GetByUsername(loginDTO.usuario, loginDTO.clave);
                if (usuario != null)
                {
                    var usuarioLoginDTO = MapperHelper.Map <Entidades.SEG_USUARIO.SEG_USUARIO, DTO.TABLAS.SEG_USUARIO.SEG_USUARIODTO>(usuario);
                    jsonResponse.Data = usuarioLoginDTO;
                }
                else
                {
                    jsonResponse.Warning = true;
                    jsonResponse.Message = Mensajes.UsuarioNoExiste;
                }
            }
            catch (Exception ex)
            {
                LogError(ex);
                jsonResponse.Success = false;
                jsonResponse.Message = Mensajes.IntenteloMasTarde;
            }

            return(jsonResponse);
        }
        public JsonResponse Add(DTO.TABLAS.SEG_USUARIO.SEG_USUARIODTO usuarioDTO)
        {
            var jsonResponse = new JsonResponse {
                Success = true
            };

            try
            {
                int resultado = 0;
                var usuario   = MapperHelper.Map <DTO.TABLAS.SEG_USUARIO.SEG_USUARIODTO, Entidades.SEG_USUARIO.SEG_USUARIO>(usuarioDTO);

                if (!SEG_USUARIOBL.Instancia.Exists(usuario))
                {
                    resultado = SEG_USUARIOBL.Instancia.Add(usuario);

                    if (resultado > 0)
                    {
                        jsonResponse.Message = Mensajes.RegistroSatisfactorio;
                    }
                    else
                    {
                        jsonResponse.Warning = true;
                        jsonResponse.Message = Mensajes.RegistroFallido;
                    }
                }
                else
                {
                    jsonResponse.Warning = true;
                    jsonResponse.Message = Mensajes.YaExisteRegistro;
                }

                LogBL.Instancia.Add(new Log
                {
                    Accion        = Mensajes.Add,
                    Controlador   = Mensajes.UsuarioController,
                    Identificador = resultado,
                    Mensaje       = jsonResponse.Message,
                    Usuario       = usuarioDTO.UsuarioCreacion,
                    Objeto        = JsonConvert.SerializeObject(usuarioDTO)
                });
            }
            catch (Exception ex)
            {
                LogError(ex);
                jsonResponse.Success = false;
                jsonResponse.Message = Mensajes.IntenteloMasTarde;

                LogBL.Instancia.Add(new Log
                {
                    Accion        = Mensajes.Add,
                    Controlador   = Mensajes.UsuarioController,
                    Identificador = 0,
                    Mensaje       = ex.Message,
                    Usuario       = usuarioDTO.UsuarioCreacion,
                    Objeto        = JsonConvert.SerializeObject(usuarioDTO)
                });
            }

            return(jsonResponse);
        }