// TODO handle cases when it fails to insert data into db
        public async Task <RentAttemptModel> RentBooks(string ssn, IEnumerable <string> isbns)
        {
            if (!MemberUtils.ValidateSsn(ssn))
            {
                throw new ArgumentException("Invalid isbn");
            }

            if (isbns == null || !isbns.Any())
            {
                throw new ArgumentException("Isbn list cannot be empty when renting books");
            }

            var member = await _memberRepository.FindBySsn(ssn);

            var role = await _memberRepository.GetRoleName(member);

            if (!Roles.CanRent(role))
            {
                return(RentAttemptModel.WhenUserIsInWrongRole());
            }

            var order = new Order()
            {
                MemberId = ssn,
                Created  = DateTime.UtcNow
            };

            var orderId = await _orderRepository.InsertAsyncWithIdReturn(order);

            foreach (var isbn in isbns)
            {
                var book = await _bookRepository.GetByIsbnAsync(isbn);

                if (!book.Loanable)
                {
                    return(RentAttemptModel.WhenOneOfTheBooksIsNotLoanable());
                }

                var availableCopies = (await _bookCopyRepository.GetByIsbnAsync(isbn))
                                      .Where(x => x.Available).ToList();
                if (availableCopies.Count == 0)
                {
                    return(RentAttemptModel.WhenOneOfTheBooksDoesntHaveCopiesAvailable());
                }

                var chosenCopy = availableCopies[0];
                chosenCopy.Available = false;

                var orderLine = BookRentUtils.CreateOrderLineModel(orderId, chosenCopy.Id);
                await _orderLineRepository.InsertAsync(orderLine);

                await _bookCopyRepository.UpdateAsync(chosenCopy);
            }
            return(RentAttemptModel.WhenSuccesful());
        }