public async Task <IActionResult> Create([Bind("Pay_ID,Pay_Name,PayDate")] Payment payment) { if (ModelState.IsValid) { _context.Add(payment); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(payment)); }
public Payment AddPayment(Payment payment) { try { payment._Student = payDb.Students.FirstOrDefault(x => x.Id == payment._Student.Id); payDb.Add(payment); payDb.SaveChanges(); return(payDb.Payments.FirstOrDefault(x => x.Pay_ID == payment.Pay_ID)); } catch (Exception) { return(null); } }