public async Task <ActionResult <Pertence> > Create([FromBody] Pertence pertence) { if (ModelState.IsValid) { _context.Pertence.Add(pertence); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(pertence); }
// GET: Pertence/Edit/5 public ActionResult Edit(int id) { ViewBag.title_page = "Pertence"; ViewBag.path = "Início / Pertence / Editar"; IEnumerable <Tipopertence> listaTipoPertence = _tipopertenceService.ObterTodos(); ViewBag.idTipoPertence = new SelectList(listaTipoPertence, "IdTipoPertence", "Nome", null); Pertence pertence = _pertenceService.Obter(id); PertenceModel pertenceModel = _mapper.Map <PertenceModel>(pertence); return(View(pertenceModel)); }
public async Task <ActionResult <Pertence> > Edit([FromBody] Pertence pertence) { if (ModelState.IsValid) { try { _context.Update(pertence); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { return(NotFound()); } return(RedirectToAction(nameof(Index))); } return(pertence); }
public void Atualizar(Pertence pertence) { _context.Update(pertence); _context.SaveChanges(); }
public int Inserir(Pertence pertence) { _context.Add(pertence); _context.SaveChanges(); return(pertence.IdPertence); }