public async Task <IActionResult> Edit(int id, BdDonation bdDonation) { if (id != bdDonation.BdDonationId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(bdDonation); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!BdDonationExists(bdDonation.BdDonationId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["CategoryId"] = new SelectList(_context.Categories, "CategoryId", "Name", bdDonation.CategoryId); ViewData["PaymentTypeId"] = new SelectList(_context.PaymentTypes, "PaymentTypeId", "Name"); return(View(bdDonation)); }
public async Task <IActionResult> Create(BdDonation bdDonation) { if (ModelState.IsValid) { _context.Add(bdDonation); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["CategoryId"] = new SelectList(_context.Categories, "CategoryId", "Name", bdDonation.CategoryId); ViewData["PaymentTypeId"] = new SelectList(_context.PaymentTypes, "PaymentTypeId", "Name"); return(View(bdDonation)); }