public async Task <IActionResult> Edit(int id, [Bind("Pay_ID,Pay_Name,PayDate")] Payment payment) { if (id != payment.Pay_ID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(payment); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PaymentExists(payment.Pay_ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(payment)); }
public Payment UpdatePayment(Payment payment) { try { Payment payment1 = (from p in payDb.Payments where p.Pay_ID == payment.Pay_ID join s in payDb.Students on p._Student.Id equals s.Id select new Payment { Pay_ID = payment.Pay_ID, PayAmount = payment.PayAmount, PayDate = payment.PayDate, Pay_Name = payment.Pay_Name, _Student = p._Student }).ToList()[0] as Payment; payDb.Update(payment1); payDb.SaveChanges(); return(payment1); } catch (Exception) { return(null); } }
public Student UpdateStudent(int id, Student student) { try { if (id.Equals(student.Id)) { student_PayDb.Update(student); student_PayDb.SaveChanges(); return(student_PayDb.Students.FirstOrDefault(x => x.Id.Equals(student.Id))); } return(null); } catch (Exception) { return(null); } }