예제 #1
0
        public ActionResult _AjaxRentBook(RentBookDTO dto)
        {
            var bookInfo = ApiRequestWithFormUrlEncodedContent.Get <EditBookDTO>($"{_inventoryApiBaseUrl}/api/Books/{dto.BookId}");

            var bookInventoryId = bookInfo.BookInventories.Where(p => p.Status == 1).FirstOrDefault()?.BookInventoryId;

            if (bookInventoryId.HasValue)
            {
                var commandId = ApiRequestWithStringContent.Post <Guid>($"{_rentalApiBaseUrl}/api/customers/{dto.CustomerId}/books", new
                {
                    BookId     = bookInventoryId,
                    BookName   = bookInfo.BookName,
                    ISBN       = bookInfo.ISBN,
                    CustomerId = dto.CustomerId,
                    Name       = new
                    {
                        FirstName  = "Lily",
                        MiddleName = string.Empty,
                        LastName   = "Jiang"
                    }
                });

                return(Json(new { result = true, commandId = commandId }));
            }
            else
            {
                return(Json(new { result = false, errorMessage = "Book has been rented, please try again." }));
            }
        }
예제 #2
0
        public ActionResult _AjaxGetAvailableBooks()
        {
            var data = ApiRequestWithFormUrlEncodedContent.Get <List <AvailableBookModel> >($"{_inventoryApiBaseUrl}/api/available_books");

            return(Json(data, JsonRequestBehavior.AllowGet));
        }
예제 #3
0
        public ActionResult Edit(Guid id)
        {
            var data = ApiRequestWithFormUrlEncodedContent.Get <EditBookDTO>($"{_inventoryApiBaseUrl}/api/Books/{id}");

            return(View(data));
        }
예제 #4
0
        public ActionResult List()
        {
            var data = ApiRequestWithFormUrlEncodedContent.Get <List <BookViewModel> >($"{_inventoryApiBaseUrl}/api/Books");

            return(View(data));
        }
예제 #5
0
        public ActionResult UnreturnedBooks()
        {
            var data = ApiRequestWithFormUrlEncodedContent.Get <List <UnreturnedBookViewModel> >($"{_rentalApiBaseUrl}/api/unreturned_books");

            return(View(data));
        }
예제 #6
0
        // GET: Customer
        public ActionResult _AjaxGetAllCustomers()
        {
            var data = ApiRequestWithFormUrlEncodedContent.Get <List <CustomerViewModel> >($"{_identityApiBaseUrl}/api/customers");

            return(Json(data, JsonRequestBehavior.AllowGet));
        }