Esempio n. 1
0
        public async Task <ActionResult <IEnumerable <Cliente> > > GetAllClientes(string nombre)
        {
            var clienteItems = await _repo.GetAll();

            if (nombre == null)
            {
                return(Ok(clienteItems));
            }

            var response = clienteItems.Where(c => c.Nombre.ToLower().Contains(nombre.ToLower()));

            return(Ok(response));
        }
Esempio n. 2
0
        private void LoadButtons()
        {
            this.navbar1.AddButtonAgregar((s, e) =>
            {
                Cliente = null;
                this.mediator.Notificar(s, "openFormularioAdd");
            });

            this.navbar1.AddButtonEditar((s, e) =>
            {
                if (Cliente == null)
                {
                    ShowAlert("No se ha seleccionado un Cliente", "Error");
                }
                else
                {
                    this.mediator.Notificar(s, "openFormularioEdit");
                }
            });

            this.navbar1.AddButtonEliminar((s, e) =>
            {
                if (Cliente == null)
                {
                    ShowAlert("No se ha seleccionado un Cliente", "Error");
                }
                else
                {
                    try
                    {
                        DeleteCliente(Cliente.Id).Wait();
                        ResetForm();
                        LoadTable().Wait();
                    }
                    catch (Exception ex)
                    {
                        ShowAlert(ex.Message, "Error");
                    }
                }
            });

            this.navbar1.AddExcelExport((s, e) =>
            {
                using (SaveFileDialog saveFileDialog = new SaveFileDialog()
                {
                    Filter = "Excel|*.xlsx"
                })
                {
                    if (saveFileDialog.ShowDialog() == DialogResult.OK)
                    {
                        try
                        {
                            var clientes = _repo.GetAll().Result.Select(p => new Cliente
                            {
                                ClaveRegistro  = p.ClaveRegistro,
                                Banco          = p.Banco,
                                Celular        = p.Celular,
                                Ciudad         = p.Ciudad,
                                ClaveBancaria  = p.ClaveBancaria,
                                Cp             = p.Cp,
                                CuentaBancaria = p.CuentaBancaria,
                                Domicilio      = p.Domicilio,
                                Email          = p.Email,
                                Estado         = p.Estado,
                                FechaAlta      = p.FechaAlta == DateTime.MinValue ? null : p.FechaAlta,
                                Paqueteria     = p.Paqueteria,
                                RazonSocial    = p.RazonSocial,
                                Representante  = p.Representante,
                                Rfc            = p.Rfc,
                                Telefono       = p.Telefono,
                            }).ToList();

                            Exportar.Excel(clientes, saveFileDialog.FileName);
                        }
                        catch (Exception er)
                        {
                            ShowAlert(er.Message, "Error");
                        }
                    }
                }
            });

            this.navbar1.AddTextFilter((s, e) =>
            {
                Cliente = null;
                ResetForm();
                LoadTable(this.navbar1.GetFilterText()).Wait();
            });
        }