コード例 #1
0
ファイル: LoanController.cs プロジェクト: JacobOJ/ITTWEB_ASS1
 public ActionResult ReturnLoan(LoanViewModel model)
 {
     var loan = _loanInformationRepo.GetByID(model.Id);
     var component = _componentRepo.GetByID(loan.Component.Id);
     component.LoanerId = null;
     _componentRepo.SaveChanges();
     return RedirectToAction("ShowComponents", "Component");
 }
コード例 #2
0
ファイル: LoanController.cs プロジェクト: JacobOJ/ITTWEB_ASS1
        public ActionResult AddLoan(int componentId)
        {
            var model = new LoanViewModel
            {
                ComponentId = componentId,
                ReturnDate = GetDefaultReturnDate(),
            };

            return View(model);
        }
コード例 #3
0
ファイル: LoanController.cs プロジェクト: JacobOJ/ITTWEB_ASS1
        public ActionResult AddLoan(LoanViewModel model)
        {
            var loaner = AutoMapper.Mapper.Map<Loaner>(model);

                var component = _componentRepo.GetByID(model.ComponentId);
                component.Loaner = loaner;
                _componentRepo.Update(component);

                var loanInformation = new LoanInformation
                {
                    ComponentId = model.ComponentId,
                    IsEmailSent = false,
                    LoanDate = DateTime.UtcNow,
                    ReturnDate = model.ReturnDate,
                    // Not sure what to do with this property, so for now it will be set to UtcNow
                    ReservationDate = DateTime.UtcNow,
                    LoanOwnerId = loaner.Id
                };

                _loanInformationRepo.Insert(loanInformation);

                return RedirectToAction("ShowComponents", "Component");
        }