public void Add(BorrowDto transaction) { if (transaction == null) { throw new ApplicationException("Cannot an add empty transaction"); } _context.BorrowTransactions.Add(transaction); _context.SaveChanges(); }
public BorrowDto MapBorrowDto(BorrowViewModel borrowViewModel) { if (borrowViewModel == null) { return null; } var borrowDto = new BorrowDto() { Id = borrowViewModel.Id, RequestDate = borrowViewModel.RequestDate, LoanDate = borrowViewModel.LoanDate, ReturnDate = borrowViewModel.ReturnDate, ItemId = borrowViewModel.ItemId, PersonId = borrowViewModel.PersonId }; return borrowDto; }
public BorrowViewModel MapBorrowViewModel(BorrowDto borrowDto) { if (borrowDto == null) { return null; } var borrow = new BorrowViewModel() { Id = borrowDto.Id, RequestDate = borrowDto.RequestDate, LoanDate = borrowDto.LoanDate, ReturnDate = borrowDto.ReturnDate, ItemId = borrowDto.ItemId, PersonId = borrowDto.PersonId, PersonName = borrowDto.Person.PersonName, PersonSurname = borrowDto.Person.Surname, ItemName = borrowDto.Item.ItemName }; return borrow; }