public async Task <IActionResult> Edit(int id, [Bind("id,tipoPagamento")] FormaPagamento formaPagamento) { if (id != formaPagamento.id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(formaPagamento); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!FormaPagamentoExists(formaPagamento.id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(formaPagamento)); }
public async Task <IActionResult> Edit(int id, [Bind("id,idFormaPagamento")] PagamentoAnuncio pagamentoAnuncio) { if (id != pagamentoAnuncio.id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(pagamentoAnuncio); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PagamentoAnuncioExists(pagamentoAnuncio.id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["idFormaPagamento"] = new SelectList(_context.FormaPagamento, "id", "tipoPagamento", pagamentoAnuncio.idFormaPagamento); return(View(pagamentoAnuncio)); }
public async Task <IActionResult> Edit(int id, [Bind("id,nomeCidade,idEstado")] Cidade cidade) { if (id != cidade.id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(cidade); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CidadeExists(cidade.id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["idEstado"] = new SelectList(_context.Estados, "id", "nomeEstado", cidade.idEstado); return(View(cidade)); }
public async Task <IActionResult> Edit(int id, [Bind("id,nomeEstado,uf")] Estados estados) { if (id != estados.id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(estados); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!EstadosExists(estados.id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(estados)); }
public async Task <IActionResult> Edit(int id, [Bind("id,statusEvento,nomeEvento,endereco,bairro,numeroResidenia,cep,descricao,email,telefone,complemento,dataInicio,dataTermino,tipoEvento,valorEvento,FotoEvento,idCliente,idCidade")] Evento evento, IFormFile NovaFoto) { if (id != evento.id) { return(NotFound()); } if (ModelState.IsValid) { try { if (NovaFoto != null) { //especificar qual é a pasta que deve salvar o arquivo string pasta = Path.Combine(webHostEnvironment.WebRootPath, "images\\eventoFotos"); var nomeArquivo = Guid.NewGuid().ToString() + "_" + NovaFoto.FileName; string caminhoArquivo = Path.Combine(pasta, nomeArquivo); using (var stream = new FileStream(caminhoArquivo, FileMode.Create)) { await NovaFoto.CopyToAsync(stream); }; evento.FotoEvento = "/images/eventoFotos/" + nomeArquivo; } _context.Update(evento); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!EventoExists(evento.id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["idCliente"] = new SelectList(_context.Clientes, "id", "nomeCliente", evento.idCliente); ViewData["idCidade"] = new SelectList(_context.Cidade, "id", "nomeCidade", evento.idCidade); ViewData["CaminhoFoto"] = webHostEnvironment.WebRootPath; return(View(evento)); }
public async Task <IActionResult> Edit(int id, [Bind("id,nomeCliente,nomeEmpresa,cepEmpresa,endereco,bairro,complemento,numeroResidencial,telefoneContato,email,senha,caminhoImagemPerfil,idCidade")] Clientes clientes, IFormFile NovaFoto) { if (id != clientes.id) { return(NotFound()); } if (ModelState.IsValid) { try { if (NovaFoto != null) { //especificar qual é a pasta que deve salvar o arquivo string pasta = Path.Combine(webHostEnvironment.WebRootPath, "images\\avatarUsuario"); var nomeArquivo = Guid.NewGuid().ToString() + "_" + NovaFoto.FileName; string caminhoArquivo = Path.Combine(pasta, nomeArquivo); using (var stream = new FileStream(caminhoArquivo, FileMode.Create)) { await NovaFoto.CopyToAsync(stream); }; clientes.caminhoImagemPerfil = "/images/avatarUsuario/" + nomeArquivo; } _context.Update(clientes); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ClientesExists(clientes.id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["idCidade"] = new SelectList(_context.Cidade, "id", "nomeCidade", clientes.idCidade); ViewData["CaminhoFoto"] = webHostEnvironment.WebRootPath; return(View(clientes)); }