public void Save(Lending lending) { if (lending == null) throw new ArgumentNullException(nameof(lending)); lending.LedingId = Guid.NewGuid(); lending.LendingStatus = LendingStatus.NotAvailable; _lendingLibraryDbContext.Lendings.Add(lending); _lendingLibraryDbContext.SaveChanges(); }
public void Update(Lending existingBorrowedItem, Lending newItem) { if (existingBorrowedItem == null) throw new ArgumentNullException(nameof(existingBorrowedItem)); if (newItem == null) throw new ArgumentNullException(nameof(newItem)); existingBorrowedItem.ItemId = newItem.ItemId; existingBorrowedItem.PersonId = newItem.PersonId; existingBorrowedItem.DateBorrowed = newItem.DateBorrowed; existingBorrowedItem.DateReturned = newItem.DateReturned; existingBorrowedItem.LendingStatus = newItem.LendingStatus; _lendingLibraryDbContext.SaveChanges(); }
private void SetPersonOn(LendingViewModel viewModel, Lending lending) { if (viewModel.PersonId != Guid.Empty) { var person = _personRepository.GetById(viewModel.PersonId); lending.PersonName = person.FirstName; } }
private void SetItemOn(LendingViewModel viewModel, Lending lending) { if (viewModel.ItemId == Guid.Empty) return; var item = _itemsRepository.GetById(viewModel.ItemId); lending.ItemName = item.ItemName; }
//Todo: add more tests for update private static FakeDbSet<Lending> CreateFakeDbSet(Lending lending = null) { return new FakeDbSet<Lending> { lending }; }
public void DeleteLending(Lending lending) { if (lending == null) throw new ArgumentNullException(nameof(lending)); _lendingLibraryDbContext.Lendings.Remove(lending); _lendingLibraryDbContext.SaveChanges(); }