public ActionResult SalvarClientes([FromBody] ClientesDto dto)
        {
            var clientes = new Clientes(dto.DataNascimento, dto.Sexo, dto.Latitude, dto.Longitude);

            _ClientesCollection.InsertOne(clientes);

            return(StatusCode(201, "Cliente adicionado com sucesso"));
        }
 public void Post(ClientesDto cliente)
 {
     ExecuteProcedure("InsCliente");
     AddParameter("@Num_Cpf", cliente.Cpf);
     AddParameter("@Nom_Nome", cliente.Nome);
     AddParameter("@Dat_Nasc", cliente.DataNasc);
     AddParameter("@Num_Tel", cliente.Tel);
     AddParameter("@Nom_End", cliente.Endereco);
     AddParameter("@Nom_Email", cliente.Email);
     ExecuteNonQuery();
 }
        public async Task <IActionResult> GetClienteById(int id)
        {
            var cliente = _clientesRepository.GetById(id);

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

            return(Ok(ClientesDto.ConverterPataDto(cliente)));
        }
Пример #4
0
        public override void Update(Action <bool, string> validatorHandler, Func <Task> OnSuccess, Action <Exception> ExceptionHandler, int id)
        {
            try
            {
                var operacionInValida = textBoxCedula.Text == "" || textBoxNombre.Text == "" || textBoxLimite.Text == "" || textBoxTarjeta.Text == "";
                validatorHandler(operacionInValida, "Debes ingresar valores a los campos obligatorios.");

                if (!operacionInValida)
                {
                    PersonaDto  Persona = _ManejadorPersona.ObtenerPorFiltro(x => x.Cedula == textBoxCedula.Text && x.Estado);
                    ClientesDto Cliente = _ManejadorCliente.ObtenerPorFiltro(x => x.TarjetaCredito == textBoxTarjeta.Text && x.Estado);

                    if (Persona == null || !isCedulaEditing)
                    {
                        if (Cliente == null)
                        {
                            Cliente = _ManejadorCliente.Obtener(id);
                            Persona = _ManejadorPersona.Obtener(Cliente.PersonaId);

                            Persona.Cedula = textBoxCedula.Text;
                            Persona.Nombre = textBoxNombre.Text;

                            _ManejadorPersona.Actualizar(Persona);

                            Cliente.TarjetaCredito = textBoxTarjeta.Text;
                            Cliente.LimiteCredito  = int.Parse(textBoxLimite.Text);

                            _ManejadorCliente.Actualizar(Cliente);

                            limpiarPantalla();
                            OnSuccess();
                        }
                        else
                        {
                            validatorHandler(true, "Ya existe un cliente con este numero de tarjeta de credito.");
                        }
                    }
                    else
                    {
                        validatorHandler(true, "Ya existe un cliente con esta cédula.");
                    }
                }
            }
            catch (Exception ex)
            {
                ExceptionHandler(ex);
            }
        }
        public IHttpActionResult Post(ClientesDto model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            ClientesDto clienteDtoInsert = null;

            try
            {
                clienteDtoInsert = clientesService.Add(model);
            }
            catch (VuelingException ex)
            {
                VuelingLogger.Logger(ex);
                throw new HttpResponseException(HttpStatusCode.NotFound);
            }
            return(CreatedAtRoute("DefaultApi",
                                  new { id = clienteDtoInsert.id }, clienteDtoInsert));
        }
Пример #6
0
        public ActionResult GuardaEdicionCliente(ClientesDto _Obj)
        {
            if (Session["StringToken"] == null)
            {
                return(RedirectToAction("Index", "Home", AutenticacionServicio.InitIndex(new Models.Seguridad.LoginModel())));
            }
            _tok = Session["StringToken"].ToString();

            var respuesta = CatalogoServicio.ModificarCliente(_Obj, _tok);

            if (respuesta.Exito)
            {
                TempData["RespuestaDTO"]      = respuesta.Mensaje;
                TempData["RespuestaDTOError"] = null;
                return(RedirectToAction("Index"));
            }

            else
            {
                TempData["RespuestaDTOError"] = respuesta;
                return(RedirectToAction("EditarCliente", "Clientes", new { id = _Obj.IdCliente }));
            }
        }
Пример #7
0
 public void Agregar(ClientesDto dto)
 {
     this.SetearDBContext(this.service);
     this.service.Agregar(dto);
     this.DisposeDBContext(this.service.DBContext);
 }
Пример #8
0
 public void Modificar(ClientesDto dto)
 {
     this.SetearDBContext(this.service);
     this.service.Modificar(dto);
     this.DisposeDBContext(this.service.DBContext);
 }
 public IHttpActionResult Put(ClientesDto cliente)
 {
     _ClientesRepository.Put(cliente);
     return(Ok());
 }
Пример #10
0
        public override void Add(Action <bool, string> validatorHandler, Func <Task> OnSuccess, Action <Exception> ExceptionHandler)
        {
            try
            {
                var operacionInValida = textBoxCedula.Text == "" || textBoxNombre.Text == "" || textBoxLimite.Text == "" || textBoxTarjeta.Text == "";
                validatorHandler(operacionInValida || !validaCedula(textBoxCedula.Text), !validaCedula(textBoxCedula.Text) ? "La cédula debe ser valida" : "Debes ingresar valores a los campos obligatorios.");

                if (!operacionInValida)
                {
                    PersonaDto Persona = _ManejadorPersona.ObtenerPorFiltro(x => x.Cedula == textBoxCedula.Text);

                    if (Persona == null)
                    {
                        Persona               = new PersonaDto();
                        Persona.Cedula        = textBoxCedula.Text;
                        Persona.Estado        = true;
                        Persona.FechaCreacion = DateTime.Now;
                        Persona.Nombre        = textBoxNombre.Text;
                        Persona.TipoPersonaId = 1;

                        Persona = _ManejadorPersona.CrearSync(Persona, true);
                    }
                    else if (Persona.Nombre != textBoxNombre.Text)
                    {
                        Persona.Nombre = textBoxNombre.Text;
                        _ManejadorPersona.Actualizar(Persona);
                    }

                    ClientesDto cliente = _ManejadorCliente.ObtenerPorFiltro(x => x.Persona.Cedula == textBoxCedula.Text && x.Estado);

                    if (cliente == null)
                    {
                        cliente = new ClientesDto();
                        cliente.TarjetaCredito = textBoxTarjeta.Text;
                        cliente.LimiteCredito  = int.Parse(textBoxLimite.Text);
                        cliente.Estado         = true;
                        cliente.PersonaId      = Persona.Id;
                        cliente.FechaCreacion  = DateTime.Now;

                        _ManejadorCliente.Crear(cliente, true);

                        limpiarPantalla();
                        OnSuccess();
                    }
                    else
                    {
                        string mensaje = "Ya existe un cliente con esta cédula.";
                        validatorHandler(true, mensaje);
                    }

                    //} else
                    //{

                    //}
                }
            }
            catch (Exception ex)
            {
                ExceptionHandler(ex);
            }
        }