private void Save()
        {
            using (var transaction = new TransactionScope()) {
                foreach (var item in _rentals)
                {
                    if (item.CrudType == BookCoreLibrary.Core.CRUDType.INSERT)
                    {
                        item.Idx = viewModel.AddRental(item);

                        if (item.Idx > 0)
                        {
                            item.CrudType = BookCoreLibrary.Core.CRUDType.NONE;
                        }
                    }
                    else if (item.CrudType == BookCoreLibrary.Core.CRUDType.MODIFY)
                    {
                        if (viewModel.ModifyRental(item))
                        {
                            item.CrudType = BookCoreLibrary.Core.CRUDType.NONE;
                        }
                    }
                }

                transaction.Complete();
            }
        }
        public HttpResponseMessage IssueBook([FromBody] Book book)
        {
            string userEmailAddress;

            if (Request.Headers.GetValues("EmailId").Count() == 0)
            {
                return(new HttpResponseMessage()
                {
                    StatusCode = HttpStatusCode.BadRequest
                });
            }

            userEmailAddress = Request.Headers.GetValues("EmailId").First();

            // validate if book is available
            if (!bookService.CheckForBookAvailability(book.Title))
            {
                return(new HttpResponseMessage()
                {
                    StatusCode = HttpStatusCode.Forbidden
                });
            }

            string userName = accountService.GetNameOfCurrentlyLoggedInUser(userEmailAddress);

            //TODO: check if rental does not already exists

            // add rental with status unapproved
            rentalService.AddRental(book.Title, userName, null);

            return(new HttpResponseMessage()
            {
                StatusCode = HttpStatusCode.Accepted
            });
        }