Exemplo n.º 1
0
        public IHttpActionResult Login(string usuario, string clave)
        {
            try
            {
                LoggerHelper.LogInfo(System.Reflection.MethodBase.GetCurrentMethod(), string.Format("Login usuario: {0} - clave: {1}", usuario, clave));

                ServicioClientes servicio = new ServicioClientes();
                Cliente          resp     = servicio.ClienteLogIn(usuario, clave);

                if (resp == null)
                {
                    return(NotFound());
                }
                LoggerHelper.LogInfo(System.Reflection.MethodBase.GetCurrentMethod(), JsonConvert.SerializeObject(resp));

                return(Ok(resp));
            }
            catch (ApplicationException ex)
            {
                LoggerHelper.LogError(MethodBase.GetCurrentMethod(), ex);
                return(BadRequest(ex.Message));
            }
            catch (Exception ex)
            {
                LoggerHelper.LogError(MethodBase.GetCurrentMethod(), ex);
                return(BadRequest("Ocurrió un error al validar el usuario."));
            }
        }
Exemplo n.º 2
0
        // POST api/cliente
        public IHttpActionResult Post([FromBody] Cliente datos)
        {
            try
            {
                ServicioClientes servicio = new ServicioClientes();
                LoggerHelper.LogInfo(System.Reflection.MethodBase.GetCurrentMethod(), JsonConvert.SerializeObject(datos));

                Cliente resp = servicio.ClienteGrabar(datos);
                if (resp == null)
                {
                    return(NotFound());
                }
                return(Ok(resp));
            }
            catch (ApplicationException ex)
            {
                LoggerHelper.LogError(MethodBase.GetCurrentMethod(), ex);
                LoggerHelper.LogError(System.Reflection.MethodBase.GetCurrentMethod(), JsonConvert.SerializeObject(datos));
                return(BadRequest(ex.Message));
            }
            catch (Exception)
            {
                return(BadRequest("El cliente no se pudo actualizar."));
            }
        }
Exemplo n.º 3
0
        public IHttpActionResult Post([FromBody] Cliente datos)
        {
            try
            {
                ServicioClientes servicio = new ServicioClientes();
                servicio.ClienteLogOut(datos.Id);

                return(Ok());
            }
            catch (Exception ex)
            {
                LoggerHelper.LogError(MethodBase.GetCurrentMethod(), ex);
                return(BadRequest(ex.Message));
            }
        }
Exemplo n.º 4
0
        public static void CargarDatosComboClientes(ref ComboBox combo)
        {
            IServicioClientes servicio = new ServicioClientes();
            var lista          = servicio.GetLista(null, null);
            var defaultCliente = new ClienteListDto()
            {
                ClienteId      = 0,
                NombreCompania = "Seleccione Cliente"
            };

            lista.Insert(0, defaultCliente);
            combo.DataSource    = lista;
            combo.ValueMember   = "ClienteId";
            combo.DisplayMember = "NombreCompania";
            combo.SelectedIndex = 0;
        }
Exemplo n.º 5
0
 public IHttpActionResult GetClientesSinLista()
 {
     try
     {
         ServicioClientes servicio = new ServicioClientes();
         List <Cliente>   resp     = servicio.ClienteBusqueda(string.Empty, true);
         if (resp == null)
         {
             return(NotFound());
         }
         return(Ok(resp));
     }
     catch (Exception ex)
     {
         return(BadRequest(ex.Message));
     }
 }
Exemplo n.º 6
0
 public IHttpActionResult GetBuscar(string buscar)
 {
     try
     {
         ServicioClientes servicio = new ServicioClientes();
         List <Cliente>   resp     = servicio.ClienteBusqueda(buscar, false);
         if (resp == null)
         {
             return(NotFound());
         }
         return(Ok(resp));
     }
     catch (Exception ex)
     {
         return(BadRequest(ex.Message));
     }
 }
Exemplo n.º 7
0
 public IHttpActionResult ListaPrecioCliente(int id)
 {
     try
     {
         ServicioClientes servicio = new ServicioClientes();
         ClienteLista     resp     = servicio.ClienteListaEliminar(id);
         if (resp == null)
         {
             return(NotFound());
         }
         return(Ok(resp));
     }
     catch (Exception ex)
     {
         return(BadRequest(ex.Message));
     }
 }
Exemplo n.º 8
0
        // GET api/cliente/5
        public IHttpActionResult Get(int id)
        {
            try
            {
                ServicioClientes servicio = new ServicioClientes();
                Cliente          resp     = servicio.ClienteObtener(id);

                if (resp == null)
                {
                    return(NotFound());
                }

                return(Ok(resp));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
Exemplo n.º 9
0
 public IHttpActionResult GetBuscarAutocompletar(string buscar)
 {
     try
     {
         ServicioClientes servicio = new ServicioClientes();
         List <string>    resp     = servicio.ClienteBusqueda(buscar, false)
                                     .OrderBy(item => item.Email)
                                     .Select(item => item.ClienteList)
                                     .ToList <string>();
         if (resp == null)
         {
             return(NotFound());
         }
         return(Ok(resp));
     }
     catch (Exception ex)
     {
         return(BadRequest(ex.Message));
     }
 }
Exemplo n.º 10
0
 public IHttpActionResult ListaPrecioCliente([FromBody] ClienteLista datos)
 {
     try
     {
         ServicioClientes servicio = new ServicioClientes();
         ClienteLista     resp     = servicio.ClienteListaGrabar(datos);
         if (resp == null)
         {
             return(NotFound());
         }
         return(Ok(resp));
     }
     catch (ApplicationException ex)
     {
         return(BadRequest(ex.Message));
     }
     catch (Exception)
     {
         return(BadRequest("La lista de precios para el cliente no se pudo actualizar."));
     }
 }
Exemplo n.º 11
0
 public StandController()
 {
     servicioCampanas = new ServicioCampanas();
     servicioClientes = new ServicioClientes();
     servicioStands   = new ServicioStands();
 }
Exemplo n.º 12
0
 // GET: Administrativa/Clientes
 public ClientesController()
 {
     servicioClientes = new ServicioClientes();
 }
Exemplo n.º 13
0
 public LogInController(IConfiguration config, ServicioClientes servicioClientes)
 {
     _config          = config;
     _servicioCliente = servicioClientes;
 }