public async Task <IActionResult> Edit(int id, [Bind("IdCliente,IdPagamento,VisitasSite,Nome,Cpf,Cep,Email,Telefone")] TbCliente tbCliente) { if (id != tbCliente.IdCliente) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(tbCliente); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TbClienteExists(tbCliente.IdCliente)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["IdPagamento"] = new SelectList(_context.Set <TbPagamento>(), "IdPagamento", "FormaPagamento", tbCliente.IdPagamento); return(View(tbCliente)); }
public async Task <IActionResult> AddCliente(TbCliente model) { if (ModelState.IsValid) { try { var clienteId = await repositorioCLiente.AddCliente(model); if (clienteId > 0) { return(Ok(clienteId)); } else { return(Ok(0)); } } catch (Exception) { return(BadRequest()); } } return(BadRequest()); }
public async Task <ActionResult <TbCliente> > PostCliente(TbCliente tbCliente) { tbCliente.FechaCreacion = DateTime.Now; tbCliente.EstadoActivo = 1; _context.TbCliente.Add(tbCliente); try { await _context.SaveChangesAsync(); } catch (DbUpdateException) { if (TbClienteExists(tbCliente.CodCliente)) { return(Conflict()); } else { throw; } } return(Ok()); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Nome,Endereco,Cpf")] TbCliente tbCliente) { if (id != tbCliente.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(tbCliente); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TbClienteExists(tbCliente.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(tbCliente)); }
private void AgregarClienteFactura() { int i = dataGridView1.CurrentRow.Index; string codigoCliente = dataGridView1.Rows[i].Cells[0].Value.ToString(); TbCliente oTbCliente = (from item in Lista.ToArray() where item.CodCliente == codigoCliente select item).Single(); onClienteSeleccionado(new object(), oTbCliente); this.Close(); }
public async Task <IActionResult> PostCliente([FromBody] TbCliente cliente) { if (cliente == null) { return(BadRequest("Cliente é null")); } await repository.Insert(cliente); return(CreatedAtAction(nameof(GetCliente), new { Id = cliente.IdCliente }, cliente)); }
public async Task <IActionResult> Create([Bind("Id,Nome,Endereco,Cpf")] TbCliente tbCliente) { if (ModelState.IsValid) { _context.Add(tbCliente); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(tbCliente)); }
public async Task <IActionResult> Create([Bind("IdCliente,IdPagamento,VisitasSite,Nome,Cpf,Cep,Email,Telefone")] TbCliente tbCliente) { if (ModelState.IsValid) { _context.Add(tbCliente); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["IdPagamento"] = new SelectList(_context.Set <TbPagamento>(), "IdPagamento", "FormaPagamento", tbCliente.IdPagamento); return(View(tbCliente)); }
public ActionResult Salvar(ClienteView cliente) { TbCliente model = cliente.ToCliente(); if (model.Id > 0) { clienteService.Update(model); } else { clienteService.Insert(model); } return(Ok(model.Id)); }
public async Task <IActionResult> PutCliente(int id, TbCliente cliente) { if (id != cliente.IdCliente) { return(BadRequest($"O código do produto {id} não confere")); } try { await repository.Update(id, cliente); } catch (DbUpdateConcurrencyException) { throw; } return(Ok("Atualização do produto realizada com sucesso")); }
public async Task <IActionResult> DeleteCliente(TbCliente model) { int result = 0; if (model == null) { return(BadRequest()); } try { result = await repositorioCLiente.DeleteCliente(model.ClienteId); return(Ok(result)); } catch (Exception) { return(BadRequest()); } }
public static Message AtualizarCliente(TbCliente cliente) { Message msg = new Message(); try { using (var proxy = new XYZServiceReference.IntegracaoServiceClient()) { proxy.AtualizarCliente(cliente); } } catch (FaultException<XYZServiceReference.BusinessFault> fe) { throw new Exception(fe.Detail.Mensagem); } catch (Exception ex) { msg.Exception = ex; } return msg; }
public async Task <IActionResult> UpdateCliente(TbCliente model) { if (ModelState.IsValid) { try { await repositorioCLiente.UpdateCliente(model); return(Ok()); } catch (Exception ex) { if (ex.GetType().FullName == "Microsoft.EntityFrameworkCore.DbUpdateConcurrencyException") { return(NotFound()); } return(BadRequest()); } } return(BadRequest()); }
private void BtnAgregarCliente_Click(object sender, EventArgs e) { String nombre = TbCliente.Text; oAtencionCliente.llenarListaClientes(nombre); lisCliente.Enqueue(nombre); foreach (var obj in oAtencionCliente.ListaCliente) { if (String.IsNullOrEmpty(nombre)) { MessageBox.Show("Campos vacios"); } else { item = new ListViewItem(obj); item.SubItems.Add("cliente numero: " + contador++); LvClientes.Items.Add(item); } } TbCliente.Clear(); oAtencionCliente.ListaCliente.Clear(); }
public async Task <IActionResult> Get(string id) { try { if (id != string.Empty) { TbCliente cliente = new TbCliente(); cliente.Id = id; var lista = await context.obtenerPorID(cliente); return(Ok(lista)); } else { return(BadRequest()); } } catch (Exception ex) { throw; } }
public JsonResult ListarClientePorId(long id) { TbCliente model = clienteService.SelectById(id) ?? new TbCliente(); return(Json(new ClienteView(model))); }
private void oFrmCliente_OnClienteSeleccionado(object sender, TbCliente e) { txtcliente.Text = e.Nombre; txtruc.Text = e.Ruc; OTbClienteTMP = e; }
private void FrmCliente_Load(object sender, EventArgs e) { Lista = TbCliente.SelectAll(); TblClientebindingSource1.DataSource = Lista; this.dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect; }