public async Task <IActionResult> Edit(int id, [Bind("CashSubcategoryId,CashSubcategoryDescription,CashCategoryId")] CashSubcategory cashSubcategory) { if (id != cashSubcategory.CashSubcategoryId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(cashSubcategory); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CashSubcategoryExists(cashSubcategory.CashSubcategoryId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["CashCategoryId"] = new SelectList(_context.CashCategory, "CashCategoryId", "CashCategoryDescription", cashSubcategory.CashCategoryId); return(View(cashSubcategory)); }
//[ValidateAntiForgeryToken] public async Task <IActionResult> Edit(int id, [Bind("CashSubcategoryId,CashSubcategoryDescription,CashCategoryId")] CashSubcategory cashSubcategory) { if (id != cashSubcategory.CashSubcategoryId) { return(NotFound()); } if (cashSubcategory.CashSubcategoryDescription.Equals("Movimiento de pago")) { ModelState.AddModelError("DataError", "No se puede crear entidad con esa descripción."); } if (ModelState.IsValid) { try { _context.Update(cashSubcategory); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CashSubcategoryExists(cashSubcategory.CashSubcategoryId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["CashCategoryId"] = new SelectList(_context.CashCategory, "CashCategoryId", "CashCategoryDescription", cashSubcategory.CashCategoryId); return(View(cashSubcategory)); }
public async Task <IActionResult> Create([Bind("CashSubcategoryId,CashSubcategoryDescription,CashCategoryId")] CashSubcategory cashSubcategory) { if (ModelState.IsValid) { _context.Add(cashSubcategory); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["CashCategoryId"] = new SelectList(_context.CashCategory, "CashCategoryId", "CashCategoryDescription", cashSubcategory.CashCategoryId); return(View(cashSubcategory)); }
//[ValidateAntiForgeryToken] public async Task <IActionResult> Create([Bind("CashSubcategoryId,CashSubcategoryDescription,CashCategoryId")] CashSubcategory cashSubcategory) { if (cashSubcategory.CashSubcategoryDescription.Equals("Movimiento de pago")) { ModelState.AddModelError("DataError", "No se puede crear entidad con esa descripción."); } if (ModelState.IsValid) { _context.Add(cashSubcategory); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["CashCategoryId"] = new SelectList(_context.CashCategory, "CashCategoryId", "CashCategoryDescription", cashSubcategory.CashCategoryId); return(View(cashSubcategory)); }