public async Task <IActionResult> Edit(int id, [Bind("Id,Cpf,Nome")] Cotista cotista) { if (id != cotista.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(cotista); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CotistaExists(cotista.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(cotista)); }
public async Task <IActionResult> PutCotista([FromRoute] int id, [FromBody] Cotista cotista) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != cotista.Id) { return(BadRequest()); } _context.Entry(cotista).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CotistaExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> Create([Bind("Id,Cpf,Nome")] Cotista cotista) { if (ModelState.IsValid) { _context.Add(cotista); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(cotista)); }
public async Task <IActionResult> PostCotista([FromBody] Cotista cotista) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.Cotistas.Add(cotista); await _context.SaveChangesAsync(); return(CreatedAtAction("GetCotista", new { id = cotista.Id }, cotista)); }