public void Remove_Deletes_RentalItem_With_RentalOrderLines()
        {
            var unitOfWorkFactory = new UnitOfWorkFactory();
            //Arrange
            var userService            = new UserService(unitOfWorkFactory);
            var itemService            = new ItemService(unitOfWorkFactory);
            var rentalItemService      = new RentalItemService(unitOfWorkFactory);
            var rentalOrderService     = new RentalOrderService(unitOfWorkFactory);
            var rentalOrderLineService = new RentalOrderLineService(unitOfWorkFactory);

            var userToAdd = UserFactory.CreateValidEntity();
            var user      = userService.Create(userToAdd);
            var itemToAdd = ItemFactory.CreateValidEntity();
            var item      = itemService.Create(itemToAdd);

            var rentalItemToAdd = RentalItemFactory.CreateValidEntity(item);
            var rentalItem      = rentalItemService.Create(rentalItemToAdd);

            var rentalOrder = rentalOrderService.Create(user.Id);

            //var rentalOrderLineToAdd = RentalOrderLineFactory.CreateValidEntity(rentalOrder, rentalItem);
            var rentalOrderLine = rentalOrderLineService.Rent(rentalOrder.Id, rentalItem.Id);

            //Act
            var result = rentalItemService.Remove(rentalItem.Id);

            //Assert
            Assert.IsTrue(result);
        }
        // rent your items
        public void Order(object sender, RoutedEventArgs e)
        {
            try // check for valid selected item
            {
                User user = (User)cbUser.SelectedItem;
                if (user != null)                   // check for not null
                {
                    if (OrderItemList.Count() != 0) // check for orderlist not empty
                    {
                        // create rental order object
                        RentalOrder rentalOrder = new RentalOrder();
                        rentalOrder.UserId        = user.Id;
                        rentalOrder.UserFirstName = user.FirstName;
                        rentalOrder.UserName      = user.Name;
                        rentalOrder.UserEmail     = user.Email;
                        rentalOrder.CreatedAt     = DateTime.Now;
                        rentalOrderService.Create(rentalOrder);

                        // get rental order id
                        var rentalOrderId = rentalOrderService.All().Last().Id;

                        // rent all the items form order table
                        foreach (var rentalItem in OrderItemList)
                        {
                            rentalOrderLineService.Rent(rentalOrderId, rentalItem.Id);
                        }
                        this.Close();
                    }
                    else
                    {
                        string mesg = "You did not select a rental item!";
                        MessageBox.Show(mesg);
                    }
                }
                else
                {
                    string mesg = "You did not select a user!";
                    MessageBox.Show(mesg);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);

                string mesg = "You did not select a user!";
                MessageBox.Show(mesg);
            }
        }