public async Task <IActionResult> Edit(int id, [Bind("Id,Numero,VlAvalicao,VlCondicional,VlLance,ProdutoId,LeilaoId")] Lote lote) { if (lote == null) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(lote); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!LoteExists(lote.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction("Details", "Leiloes", new { Id = lote.LeilaoId })); } return(View(lote)); }
public async Task <IActionResult> Edit(int id, Leilao leilao) { if (id != leilao.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(leilao); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!LeilaoExists(leilao.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(leilao)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Descricao,Data,TaxaAvaliacao,TaxaVenda,LeiloeiroId")] Leilao leilao) { if (id != leilao.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(leilao); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!LeilaoExists(leilao.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["LeiloeiroId"] = new SelectList(_context.Leiloeiro, "Id", "Id", leilao.LeiloeiroId); return(View(leilao)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Nome,Telefone,Site,TaxaAvaliacaoPadrao,TaxaVendaPadrao")] Leiloeiro leiloeiro) { if (id != leiloeiro.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(leiloeiro); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!LeiloeiroExists(leiloeiro.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(leiloeiro)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Numero,VlAvalicao,VlCondicional,VlLance,ProdutoId,LeilaoId")] Lote lote) { if (id != lote.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(lote); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!LoteExists(lote.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["LeilaoId"] = new SelectList(_context.Leilao, "Id", "Id", lote.LeilaoId); return(View(lote)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,OlxIdVendedor,Nome")] VendedorProibido vendedorProibido) { if (id != vendedorProibido.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(vendedorProibido); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!VendedorProibidoExists(vendedorProibido.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(vendedorProibido)); }
//POST: Atualizar NotView em anuncio public async Task <bool> UpdateNotView(bool notView, int id) { var anuncio = await _context.Anuncio.FindAsync(id); if (anuncio == null) { return(false); } anuncio.NotView = notView; if (ModelState.IsValid) { try { _context.Update(anuncio); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { return(false); } } return(true); }
//[Authorize(Roles = "Administrator")] public async Task <IActionResult> Edit(string id, Usuario Usuario) { if (id != Usuario.Id) { return(NotFound()); } if (ModelState.IsValid) { var UsuarioAtual = await _context.Usuario.FindAsync(id); if (Usuario.UserName != UsuarioAtual.UserName) { var pathAntigo = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot/img/avatars", UsuarioAtual.UserName + ".jpg"); var pathNovo = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot/img/avatars", Usuario.UserName + ".jpg"); var setUserNameResult = await _userManager .SetUserNameAsync(UsuarioAtual, Usuario.UserName); if (!setUserNameResult.Succeeded) { throw new InvalidOperationException( $"Erro ao alterar o Nome de Usuário: '{Usuario.UserName}'."); } if (System.IO.File.Exists(pathAntigo)) { System.IO.File.Move(pathAntigo, pathNovo); System.IO.File.Delete(pathAntigo); } else if (!System.IO.File.Exists(pathNovo)) { CriarAvatar(avatarDefault, Usuario.UserName); } } if (Usuario.Email != UsuarioAtual.Email) { var setEmailResult = await _userManager .SetEmailAsync(UsuarioAtual, Usuario.Email); if (!setEmailResult.Succeeded) { throw new InvalidOperationException($"Erro ao alterar o email do usuário: '{Usuario.UserName}'."); } } if (Usuario.PhoneNumber != UsuarioAtual.PhoneNumber) { var setPhoneResult = await _userManager .SetPhoneNumberAsync(UsuarioAtual, Usuario.PhoneNumber); if (!setPhoneResult.Succeeded) { throw new InvalidOperationException($"Erro ao alterar o telefone do usuário: '{Usuario.UserName}'."); } } if (Usuario.LockoutEnd != UsuarioAtual.LockoutEnd) { Usuario.LockoutEnd = null; var setLockoutEndResult = await _userManager .SetLockoutEndDateAsync(UsuarioAtual, Usuario.LockoutEnd); if (!setLockoutEndResult.Succeeded) { throw new InvalidOperationException($"Erro ao alterar o LockoutEnd do usuário: '{Usuario.UserName}'."); } } if (Usuario.EmailConfirmed != UsuarioAtual.EmailConfirmed) { UsuarioAtual.EmailConfirmed = Usuario.EmailConfirmed; } UsuarioAtual.Nome = Usuario.Nome; UsuarioAtual.Endereco = Usuario.Endereco; UsuarioAtual.Celular = Usuario.Celular; try { _context.Update(UsuarioAtual); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!UsuarioExists(Usuario.Id)) { return(NotFound()); } else { throw; } } if (Usuario.UserName == User.Identity.Name) { return(RedirectToAction(nameof(Index))); } return(RedirectToAction(nameof(Lista))); } return(View(Usuario)); }