public bool CreateLoan(LoanCreate model) { var loanEntity = new Loan() { OwnerID = _userID, LoanedGeckoID = model.LoanedGeckoID, LoanedGeckoName = model.LoanedGeckoName, LeaseeName = model.LeaseeName, LoanStart = model.LoanStart, LoanDuration = model.LoanDuration }; using (var ctx = new ApplicationDbContext()) { ctx.Loans.Add(loanEntity); return(ctx.SaveChanges() == 1); } }
public ActionResult Create(LoanCreate model) { if (!ModelState.IsValid) { return(View(model)); } var service = CreateLoanService(); if (service.CreateLoan(model)) { TempData["SaveResult"] = "Loan information has been entered sucessfully."; return(RedirectToAction("Index")); } ; ModelState.AddModelError("", "Loan information was not saved."); return(View(model)); }
public IHttpActionResult Loan(LoanCreate request) { _loanService.Create(request); return(Ok()); }