public async Task <IActionResult> Order(int bookId)
        {
            String token = orderBookToken;

            if (token == null)
            {
                var payment = await getToken(
                    new DateRange(DateTime.Today, DateTime.Today.AddDays(2.0)), "OrderBook");

                if (payment is ErrorViewModel)
                {
                    return(View("~/Views/Shared/Error.cshtml", payment));
                }
                token = payment as String;
            }

            LibraryServiceSoapClient.EndpointConfiguration endpointConfiguration = LibraryServiceSoapClient.EndpointConfiguration.LibraryServiceSoap;
            var client  = new LibraryServiceSoapClient(endpointConfiguration);
            var request = new OrderBookRequest();

            request.Body = new OrderBookRequestBody(defaultToken, bookId);
            var result = await client.OrderBookAsync(defaultToken, bookId);

            if (result.Body.OrderBookResult == false)
            {
                return(View("Error"));
            }


            return(Redirect("AllBooks"));
        }
        public async Task <IActionResult> AllAvailableBooks()
        {
            String token = getAllBooksToken;

            if (token == null)
            {
                var payment = await getToken(
                    new DateRange(DateTime.Today, DateTime.Today.AddDays(2.0)), "GetAllBooks");

                if (payment is ErrorViewModel)
                {
                    return(View("~/Views/Shared/Error.cshtml", payment));
                }
                token = payment as String;
            }

            LibraryServiceSoapClient.EndpointConfiguration endpointConfiguration = LibraryServiceSoapClient.EndpointConfiguration.LibraryServiceSoap;
            var client  = new LibraryServiceSoapClient(endpointConfiguration);
            var request = new GetAllAvailableBooksRequest();

            request.Body = new GetAllAvailableBooksRequestBody(token);

            var result = await client.GetAllAvailableBooksAsync(token);

            if (result.Body.GetAllAvailableBooksResult == null || result.Body.GetAllAvailableBooksResult.Length == 0)
            {
                return(View("Error"));
            }
            return(View(result.Body.GetAllAvailableBooksResult.ToList()));
        }
        private async Task <Object> GetAllBooks()
        {
            String token = getAllBooksToken;

            if (token == null)
            {
                var payment = await getToken(
                    new DateRange(DateTime.Today, DateTime.Today.AddDays(2.0)), "GetAllBooks");

                if (payment is ErrorViewModel)
                {
                    return(payment);
                }
                token = payment as String;
            }


            LibraryServiceSoapClient.EndpointConfiguration endpointConfiguration = LibraryServiceSoapClient.EndpointConfiguration.LibraryServiceSoap;
            var client  = new LibraryServiceSoapClient(endpointConfiguration);
            var request = new GetAllBooksRequest();

            request.Body = new GetAllBooksRequestBody(defaultToken);

            var result = await client.GetAllBooksAsync(token);

            return(result);
        }
示例#4
0
        private async Task <GetAllBooksResponse> GetAllBooks()
        {
            LibraryServiceSoapClient.EndpointConfiguration endpointConfiguration = LibraryServiceSoapClient.EndpointConfiguration.LibraryServiceSoap;
            var client  = new LibraryServiceSoapClient(endpointConfiguration);
            var request = new GetAllBooksRequest();

            request.Body = new GetAllBooksRequestBody(token);

            var result = await client.GetAllBooksAsync(request);

            return(result);
        }
        public async Task <IActionResult> Return(int bookId)
        {
            LibraryServiceSoapClient.EndpointConfiguration endpointConfiguration = LibraryServiceSoapClient.EndpointConfiguration.LibraryServiceSoap;
            var client  = new LibraryServiceSoapClient(endpointConfiguration);
            var request = new ReturnBookRequest();

            request.Body = new ReturnBookRequestBody(defaultToken, bookId);
            var result = await client.ReturnBookAsync(defaultToken, bookId);

            if (result.Body.ReturnBookResult == false)
            {
                return(View("Error"));
            }

            return(Redirect("AllBooks"));
        }
示例#6
0
        public async Task <IActionResult> AllAvailableBooks()
        {
            LibraryServiceSoapClient.EndpointConfiguration endpointConfiguration = LibraryServiceSoapClient.EndpointConfiguration.LibraryServiceSoap;
            var client  = new LibraryServiceSoapClient(endpointConfiguration);
            var request = new GetAllAvailableBooksRequest();

            request.Body = new GetAllAvailableBooksRequestBody(token);

            var result = await client.GetAllAvailableBooksAsync(request);

            if (result.Body.GetAllAvailableBooksResult == null || result.Body.GetAllAvailableBooksResult.Length == 0)
            {
                return(View("Error"));
            }
            return(View(result.Body.GetAllAvailableBooksResult.ToList()));
        }