예제 #1
0
        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);
            }
        }
예제 #2
0
        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));
        }
예제 #3
0
 public IHttpActionResult Loan(LoanCreate request)
 {
     _loanService.Create(request);
     return(Ok());
 }