コード例 #1
0
ファイル: Book.cs プロジェクト: TonyZhangshi81/Example_MVC
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public List <Example_Models.Entities.Book> GetBooks()
        {
            var apiRequestHttp = new ApiRequestHttp();

            apiRequestHttp.HttpPostSync(@"http://localhost/BookServer/BookService.svc/GetBooks", string.Empty);

            var json  = apiRequestHttp.OutputJson;
            var books = ApiRequestHttp.Deserialize <ApiGetBooksType>(json);

            return(books.GetBooksResult);
        }
コード例 #2
0
ファイル: Book.cs プロジェクト: TonyZhangshi81/Example_MVC
        /// <summary>
        ///
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public Example_Models.Entities.Book GetBook(string id)
        {
            var apiRequestHttp = new ApiRequestHttp();

            var data = new
            {
                id = id
            };

            apiRequestHttp.HttpPostSync(@"http://localhost/BookServer/BookService.svc/GetBook", data);

            var json = apiRequestHttp.OutputJson;
            var book = ApiRequestHttp.Deserialize <ApiGetBookWithIdType>(json);

            return(book.GetBookResult);
        }
コード例 #3
0
ファイル: Book.cs プロジェクト: TonyZhangshi81/Example_MVC
        /// <summary>
        ///
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public bool Delete(string id)
        {
            var apiRequestHttp = new ApiRequestHttp();

            var requestAll = new
            {
                metadata = new { requestid = "DEL01" },
                request  = new { id = id }
            };

            apiRequestHttp.HttpPostSync(@"http://localhost/BookServer/BookService.svc/Delete", requestAll);

            var json   = apiRequestHttp.OutputJson;
            var result = ApiRequestHttp.Deserialize <ResponseObject <ResponseMetadata, ApiDeleteBookWithIdResponse> >(json);

            ExtBooleanConverter booleanConverter = new ExtBooleanConverter();

            return((bool)booleanConverter.ConvertFrom(result.Response.Result));
        }