public async Task <IActionResult> Edit(int id, [Bind("Id,Tip_Descripcion")] TiposPagotbl tiposPagotbl) { if (id != tiposPagotbl.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(tiposPagotbl); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TiposPagotblExists(tiposPagotbl.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(tiposPagotbl)); }
public async Task <IActionResult> Create([Bind("Id,Tip_Descripcion")] TiposPagotbl tiposPagotbl) { if (ModelState.IsValid) { try { _context.Add(tiposPagotbl); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } catch (Exception ex) { if (ex.InnerException.Message.Contains("duplicate")) { ModelState.AddModelError(string.Empty, "El tipo de pago ya existe"); } else { ModelState.AddModelError(string.Empty, ex.InnerException.Message); } } } return(View(tiposPagotbl)); }