コード例 #1
0
        public void CreateLoan(LoanViewModel model)
        {
            int nextId = 0;

            if (Storage.Loans.Count > 0)
            {
                nextId = Storage.Loans.Last().Id + 1;
            }
            var loan = new Loan();
            var book = _bookRepository.GetItemDetails(int.Parse(model.SelectedBook));
            var user = _userService.FindLoggedUser();

            loan.Id       = nextId;
            loan.Book     = book;
            loan.User     = user;
            loan.Status   = LoanStatusEnum.Active;
            loan.LoanDate = DateTime.Now;
            _loanRepository.CreateNew(loan);
        }