public async Task <ActionResult <ClienteItem> > PostClienteItem(ClienteItem item)
        {
            _context.ClienteItems.Add(item);
            await _context.SaveChangesAsync();

            return(CreatedAtAction(nameof(GetClienteItem), new { id = item.Id }, item));
        }
        public async Task <ActionResult <Cliente> > PostCliente(Cliente cliente)
        {
            _context.Cliente.Add(cliente);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetCliente", new { id = cliente.Id }, cliente));
        }
Beispiel #3
0
        public async Task <IActionResult> PutEndereco(int id, Endereco endereco)
        {
            if (id != endereco.Id)
            {
                return(BadRequest());
            }

            _context.Entry(endereco).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!EnderecoExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        //[Authorize(Roles = "admin,vendedor")]

        public async Task <IActionResult> PutProduct(int id, Product product)
        {
            if (id != product.id)
            {
                return(BadRequest());
            }

            _context.Entry(product).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ProductExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public async Task <IActionResult> PutCliente([FromRoute] int id, [FromBody] Cliente cliente)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != cliente.Id)
            {
                return(BadRequest());
            }

            _context.Entry(cliente).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ClienteExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Beispiel #6
0
        public async Task <IActionResult> CreateClientes([FromBody] Cliente cliente)
        {
            _context.Clientes.Add(cliente);
            await _context.SaveChangesAsync();

            return(Ok(cliente));
        }
        //[Authorize(Roles = "admin")]

        public async Task <IActionResult> PutNaturalPerson(int id, NaturalPerson naturalPerson)
        {
            if (id != naturalPerson.id)
            {
                return(BadRequest());
            }

            _context.Entry(naturalPerson).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!NaturalPersonExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        //[Authorize(Roles = "admin,vendedor")]
        public async Task <IActionResult> PutCustomers(int id, Customers customers)
        {
            if (id != customers.id)
            {
                return(BadRequest());
            }

            _context.Entry(customers).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CustomersExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public async Task <IActionResult> PutCliente(long id, Cliente cliente)
        {
            var header = Request.Headers["X-Debug"];

            if (id != cliente.Id)
            {
                return(BadRequest());
            }

            _context.Entry(cliente).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ClienteExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            if (header.ToString() == "true")
            {
                AddHttpHeaders(Response);
                printLog();
            }

            return(NoContent());
        }
Beispiel #10
0
        public async Task <TEntity> AddAsync(TEntity entity)
        {
            await _context.Set <TEntity>().AddAsync(entity);

            await _context.SaveChangesAsync();

            return(entity);
        }
        public async Task <IActionResult> Create([Bind("ClienteId,nome,CPF,Email,DataCadastro")] Cliente cliente)
        {
            if (ModelState.IsValid)
            {
                _context.Add(cliente);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(cliente));
        }
Beispiel #12
0
        public async Task <IActionResult> Create([Bind("ClienteID,Cedula,Nombre,Correo,Direccion,Genero")] Cliente cliente)
        {
            if (ModelState.IsValid)
            {
                _context.Add(cliente);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(cliente));
        }
        public async Task <IActionResult> Create([Bind("ID,Nome,Cpf,DataNascimento,Status,Sexo")] Cliente cliente)
        {
            if (ModelState.IsValid)
            {
                _context.Add(cliente);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(cliente));
        }
        public async Task <IActionResult> Create([Bind("ClienteId,Cedula,Nombre,Apellido,Edad,Telefono,Email,Cliente_Genero,Estado_civil,Leer,Cantar,Bailar,Escribir")] Cliente cliente)
        {
            if (ModelState.IsValid)
            {
                _context.Add(cliente);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(cliente));
        }
Beispiel #15
0
        public async Task <ActionResult <VehiculoItem> > PostVehiculoItem(VehiculoItem item)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            _context.VehiculoItems.Add(item);
            await _context.SaveChangesAsync();

            return(CreatedAtAction(nameof(GetVehiculoItem), new { id = item.Placa }, item));
        }
        public async Task <IActionResult> Create(Cliente cliente)
        {
            if (ModelState.IsValid)
            {
                _context.Add(cliente);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(cliente));
        }
Beispiel #17
0
        public async Task <IActionResult> Create([Bind("id_cliente,nombre_cliente,direccion,telefono,tipo_cliente,pais,departamento,ciudad")] Cliente cliente)
        {
            if (ModelState.IsValid)
            {
                _context.Add(cliente);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(cliente));
        }
Beispiel #18
0
        public async Task <ActionResult <ReservaItem> > PostReservaItem(ReservaItem item)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            _context.ReservaItems.Add(item);
            await _context.SaveChangesAsync();

            return(CreatedAtAction(nameof(GetReservaItem), new { id = item.Id }, item));
        }
Beispiel #19
0
        public async Task <IActionResult> Create(/*[Bind("Id,Nome,CPF,RG, Email, Telefone")] */ Cliente cliente)
        {
            if (ModelState.IsValid)
            {
                _context.Add(cliente);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(cliente));
        }
Beispiel #20
0
        public async Task <int> AddCliente(Cliente cliente)
        {
            if (_context != null)
            {
                await _context.clientes.AddAsync(cliente);

                await _context.SaveChangesAsync();

                return(cliente.id);
            }
            return(0);
        }
        public async Task <IActionResult> Create([Bind("ClienteId,Rnc,Nombre,Direccion,Lat,Long,Telefono,Correo,Contador,MontoTotal,FechaCumpleaños")] Cliente cliente)
        {
            if (ModelState.IsValid)
            {
                cliente.MontoTotal = 0;
                cliente.Contador   = 0;
                _context.Add(cliente);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(cliente));
        }
        public async Task <ActionResult <Cliente> > StoreCliente(Cliente cliente)
        {
            _context.Clientes.Add(cliente);
            await _context.SaveChangesAsync();

            return(CreatedAtAction(nameof(GetCliente), new { id = cliente.Id }, cliente));
        }
Beispiel #23
0
        public async Task <IActionResult> AddOrEdit([Bind("ClienteId,CPF,Nome,SiglaEstado")] Cliente cliente)
        {
            if (ModelState.IsValid)
            {
                if (cliente.ClienteId == 0)
                {
                    _context.Add(cliente);
                }
                else
                {
                    _context.Update(cliente);
                }
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(cliente));
        }
        public async Task <IActionResult> AddOrEdit([Bind("ClienteID,Pasaporte,Cedula,NombreCompleto,Nacionalidad,Direccion")] Cliente cliente)
        {
            if (ModelState.IsValid)
            {
                if (cliente.ClienteID == 0)
                {
                    _context.Add(cliente);
                }
                else
                {
                    _context.Update(cliente);
                }
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(cliente));
        }
        public async Task <IActionResult> AddOrEdit([Bind("IdServicio,Nombre_Servic,Precio,Descripcion,Contador")] Servicio servicio)
        {
            if (ModelState.IsValid)
            {
                servicio.Contador = 0;
                if (servicio.IdServicio == 0)
                {
                    _context.Add(servicio);
                }
                else
                {
                    _context.Update(servicio);
                }
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(servicio));
        }
Beispiel #26
0
        public async Task <IActionResult> AddOrEdit([Bind("IdProducto,Nombre_Produc,Precio,Cantidad,Contador")] Productos productos)
        {
            if (ModelState.IsValid)
            {
                productos.Contador = 0;
                if (productos.IdProducto == 0)
                {
                    _Context.Add(productos);
                }
                else
                {
                    _Context.Update(productos);
                }
                await _Context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(productos));
        }
        public async Task <ActionResult <ClienteItem> > PostClienteItem(ClienteItem item)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest("Error"));
            }

            //var clienteItem = await _context.ClienteItems.FindAsync(id);

            //if(clienteItem!=null)
            //{
            //  return BadRequest("Ya la persona esta registrada");
            //}

            _context.ClienteItems.Add(item);
            await _context.SaveChangesAsync();

            return(CreatedAtAction(nameof(GetClienteItem), new { id = item.Identificacion }, item));
        }
Beispiel #28
0
        public async Task <IActionResult> Create([Bind("id,dni,nombre,domicilio")] Cliente cliente)
        {
            string codigoGrupo = "75263b76-71fc-4d0e-b5e6-7daa8e947319";
            ServicioPublicoCreditoClient cli = new ServicioPublicoCreditoClient();
            var response = cli.ObtenerEstadoClienteAsync(codigoGrupo, cliente.dni).Result;

            ViewData["creditos"]    = response.CantidadCreditosActivos;
            ViewData["esValida"]    = response.ConsultaValida;
            ViewData["tieneDeudas"] = response.TieneDeudas;
            ViewData["error"]       = response.Error;
            if (ModelState.IsValid & response.Error == null)
            {
                _context.Add(cliente);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(cliente));
        }
Beispiel #29
0
        public async Task <bool> Excluir(Guid id)
        {
            using (var context = new ClienteContext())
            {
                var clienteDb = await context.Clientes.FirstAsync(f => f.Id == id);

                context.Clientes.Remove(clienteDb);

                return((await context.SaveChangesAsync()) > 0);
            }
        }
Beispiel #30
0
        public async Task <Models.Cliente> Atualizar(Models.Cliente cliente)
        {
            using (var context = new ClienteContext())
            {
                context.Entry(await context.Clientes.FirstOrDefaultAsync(f => f.Id == cliente.Id)).CurrentValues.SetValues(cliente);

                if ((await context.SaveChangesAsync()) > 0)
                {
                    return(cliente);
                }

                return(null);
            }
        }