Пример #1
0
 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
        public ActionResult AddLoan(int componentId)
        {
            var model = new LoanViewModel
            {
                ComponentId = componentId,
                ReturnDate = GetDefaultReturnDate(),
            };

            return View(model);
        }
Пример #3
0
        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");
        }