Ejemplo n.º 1
0
        public async Task <System.Net.HttpStatusCode> DeleteBookAsync(int bookId)
        {
            HttpClient          client   = HttpClients.GetInstance();
            HttpResponseMessage response = await client.DeleteAsync("books/delete/" + bookId);

            return(response.StatusCode);
        }
Ejemplo n.º 2
0
        public async Task <System.Net.HttpStatusCode> DeleteAuthorAsync(int authorId)
        {
            HttpClient          client   = HttpClients.GetInstance();
            HttpResponseMessage response = await client.DeleteAsync("authors/delete/" + authorId);

            return(response.StatusCode);
        }
        public async Task <System.Net.HttpStatusCode> DeleteBookCategoryAsync(int BookCategoryID)
        {
            HttpClient          client   = HttpClients.GetInstance();
            HttpResponseMessage response = await client.DeleteAsync("bookcategories/delete/" + BookCategoryID);

            return(response.StatusCode);
        }
Ejemplo n.º 4
0
        public async Task <bool> EditBookAsync(Models.Book book)
        {
            HttpClient          client   = HttpClients.GetInstance();
            HttpResponseMessage response = await client.PutAsJsonAsync("books/update/", book);

            if (!response.IsSuccessStatusCode)
            {
                return(false);;
            }
            return(true);
        }
Ejemplo n.º 5
0
        public async Task <bool> EditAuthorAsync(Models.Author author)
        {
            HttpClient          client   = HttpClients.GetInstance();
            HttpResponseMessage response = await client.PutAsJsonAsync("authors/update/", author);

            if (!response.IsSuccessStatusCode)
            {
                return(false);;
            }
            return(true);
        }
        public async Task <bool> AddNewBookCategoryAsync(Models.BookCategory BookCategory)
        {
            HttpClient          client   = HttpClients.GetInstance();
            HttpResponseMessage response = await client.PostAsJsonAsync("bookcategories/create", BookCategory);

            if (!response.IsSuccessStatusCode)
            {
                return(false);;
            }
            return(true);
        }
Ejemplo n.º 7
0
        public async Task <Models.Book> GetBookAsync(int bookId)
        {
            HttpClient client = HttpClients.GetInstance();

            Models.Book         book     = null;
            HttpResponseMessage response = await client.GetAsync("books/getbyid/" + bookId);

            if (response.IsSuccessStatusCode)
            {
                book = await response.Content.ReadAsAsync <Models.Book>();
            }
            return(book);
        }
Ejemplo n.º 8
0
        public async Task <Models.Author> GetAuthorAsync(int authorId)
        {
            HttpClient client = HttpClients.GetInstance();

            Models.Author       author   = null;
            HttpResponseMessage response = await client.GetAsync("authors/getbyid/" + authorId);

            if (response.IsSuccessStatusCode)
            {
                author = await response.Content.ReadAsAsync <Models.Author>();
            }
            return(author);
        }
        public async Task <Models.BookCategory> GetBookCategoryAsync(int BookCategoryID)
        {
            HttpClient client = HttpClients.GetInstance();

            Models.BookCategory bookCategory = null;
            HttpResponseMessage response     = await client.GetAsync("bookcategories/getbyid/" + BookCategoryID);

            if (response.IsSuccessStatusCode)
            {
                bookCategory = await response.Content.ReadAsAsync <Models.BookCategory>();
            }
            return(bookCategory);
        }
Ejemplo n.º 10
0
        public async Task <List <Models.Book> > GetAllBooksAsync()
        {
            HttpClient client = HttpClients.GetInstance();

            HttpResponseMessage response = await client.GetAsync("books/getall");

            List <Models.Book> listBook = null;

            if (response.IsSuccessStatusCode)
            {
                listBook = await response.Content.ReadAsAsync <List <Models.Book> >();
            }

            return(listBook);
        }
Ejemplo n.º 11
0
        public async Task <List <Models.Author> > GetAllAuthorsAsync()
        {
            HttpClient client = HttpClients.GetInstance();

            HttpResponseMessage response = await client.GetAsync("authors/getall");



            List <Models.Author> listAuthor = null;

            if (response.IsSuccessStatusCode)
            {
                listAuthor = await response.Content.ReadAsAsync <List <Models.Author> >();
            }

            return(listAuthor);
        }