public async Task <IActionResult> Edit(int id, [Bind("Id,Nome,Sobrenome,TurmaId")] Aluno aluno) { if (id != aluno.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(aluno); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AlunoExists(aluno.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(aluno)); }
public async Task <IActionResult> Edit(string id, [Bind("ID,Name,Email,PhoneNumber")] Dealership dealership) { if (id != dealership.ID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(dealership); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DealershipExists(dealership.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(dealership)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Make,Model,Year,VIN,Colour,DealershipID")] Car car) { if (id != car.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(car); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CarExists(car.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(car)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Nome,Sobrenome,Email,DataDeNascimento")] Autor autor) { if (id != autor.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(autor); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AutorExists(autor.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(autor)); }
public async Task <IActionResult> Edit(string id, [Bind("FirstName,LastName,UserName,Email,Company,Position,BirthDate")] Member member) { if (id != member.UserName) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(member); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!MemberExists(member.UserName)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(member)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Nome")] Turma turma) { if (id != turma.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(turma); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TurmaExists(turma.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(turma)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Titulo,ISBN,Ano,AutorId")] Livro livro) { if (id != livro.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(livro); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!LivroExists(livro.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(livro)); }
//[ValidateAntiForgeryToken] public async Task <IActionResult> Edit(int id, [FromBody] userLogin userLogin) { if (id != userLogin.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(userLogin); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!userLoginExists(userLogin.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(userLogin)); }
private string setToken(userLogin user) { user.Token = Guid.NewGuid().ToString(); _context.Update(user); _context.SaveChanges(); return(user.Token); }
public void Update(TodoItem todoItem) { var todoItemUpdate = GetById(todoItem.Id); todoItemUpdate.Name = todoItem.Name; todoItemUpdate.IsComplete = todoItem.IsComplete; _context.Update(todoItemUpdate); _context.SaveChanges(); }
public IActionResult Put(Category category) { using var context = new WebApiContext(); //var response = context.Categories.Find(category.Id); var response = context.Find <Category>(category.Id); if (response == null) { return(NotFound()); } response.Name = category.Name; context.Update(response); context.SaveChanges(); return(NoContent()); }
public async Task <ActionResult <User> > Put(User user) { if (user == null) { return(BadRequest()); } if (!_context.Users.Any(x => x.Id == user.Id)) { return(NotFound()); } _context.Update(user); await _context.SaveChangesAsync(); return(Ok(user)); }
public async Task <IActionResult> Put(Ticket ticket) { if (ticket == null) { return(BadRequest()); } if (!_context.Tickets.Any(x => x.Id == ticket.Id)) { return(NotFound()); } _context.Update(ticket); await _context.SaveChangesAsync(); return(Ok(ticket)); }
//public IEnumerable<Pessoa> List(Guid id, string nome, string sobreNome, string rg) //{ // var pessoas = _context.Pessoa.AsQueryable(); // if (id != Guid.Empty && id != null) // pessoas = pessoas.Where(x => x.Id == id); // if (string.IsNullOrWhiteSpace(nome) == false) // pessoas = pessoas.Where(x => x.Nome == nome); // if (string.IsNullOrWhiteSpace(sobreNome) == false) // pessoas = pessoas.Where(x => x.Sobrenome == sobreNome); // if (string.IsNullOrWhiteSpace(rg) == false) // pessoas = pessoas.Where(x => x.Rg == rg); // return pessoas.AsNoTracking().ToList(); //} public Task Update(Pet pet) { _context.Update(pet); return(_context.SaveChangesAsync()); }