public void AddLoanInformation(LoanInformation loan) { dbContext.LoanInformation.Add(loan); dbContext.SaveChanges(); }
public ActionResult SaveLoanInformation(int ComponentId, int SpecificComponentId, string ComponentName, string Name, string Email, string LoanDate, string ReturnDate, int LoanId) { LoanInformation updatedLoan = new LoanInformation(); updatedLoan.LoanDate = DateTime.Parse(LoanDate); updatedLoan.ReturnDate = DateTime.Parse(ReturnDate); updatedLoan.SpecCompId = SpecificComponentId; updatedLoan.LoaneeName = Name; updatedLoan.LoaneeEmail = Email; updatedLoan.LoanId = LoanId; writeToDb.UpdateLoanInformation(LoanId, updatedLoan); return RedirectToAction("DetailsView", new { id = ComponentId }); }
public void UpdateLoanInformation(int loanId, LoanInformation loan) { var itemToUpdate = dbContext.LoanInformation.SingleOrDefault(x => x.LoanId == loanId); if (itemToUpdate != null) { itemToUpdate = loan; dbContext.SaveChanges(); } }