This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async Task MyAPIDelete(HttpClient cons) | |
{ | |
using (cons) | |
{ | |
HttpResponseMessage res = await cons.GetAsync("api/tblTags/2"); | |
res.EnsureSuccessStatusCode(); | |
if (res.IsSuccessStatusCode) | |
{ | |
res = await cons.DeleteAsync("api/tblTags/2"); | |
Console.WriteLine("\n"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tag.tagName = "New Tag"; | |
res = await cons.PutAsJsonAsync("api/tblTags/2", tag); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static async Task MyAPIPut(HttpClient cons) | |
{ | |
using (cons) | |
{ | |
HttpResponseMessage res = await cons.GetAsync("api/tblTags/2"); | |
res.EnsureSuccessStatusCode(); | |
if (res.IsSuccessStatusCode) | |
{ | |
tblTag tag = await res.Content.ReadAsAsync<tblTag>(); | |
tag.tagName = "New Tag"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static async Task MyAPIGet(HttpClient cons) | |
{ | |
using (cons) | |
{ | |
HttpResponseMessage res = await cons.GetAsync("api/tblTags/2"); | |
res.EnsureSuccessStatusCode(); | |
if (res.IsSuccessStatusCode) | |
{ | |
tblTag tag = await res.Content.ReadAsAsync<tblTag>(); | |
Console.WriteLine("\n"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
HttpClient cons = new HttpClient(); | |
cons.BaseAddress = new Uri("http://localhost:7967/"); | |
cons.DefaultRequestHeaders.Accept.Clear(); | |
cons.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class tblTag | |
{ | |
public int tagId { get; set; } | |
public string tagName { get; set; } | |
public string tagDescription { get; set; } | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
namespace WebAPIWithHttpClientConsumer | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Data; | |
using System.Data.Entity; | |
using System.Data.Entity.Infrastructure; | |
using System.Linq; | |
using System.Net; | |
using System.Net.Http; | |
using System.Threading.Tasks; | |
using System.Web.Http; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
USE [TrialsDB] | |
GO | |
INSERT INTO [dbo].[tblTags] | |
([tagName] | |
,[tagDescription]) | |
VALUES | |
(<tagName, nvarchar(50),> | |
,<tagDescription, nvarchar(max),>) | |
GO |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
USE [TrialsDB] | |
GO | |
/****** Object: Table [dbo].[tblTags] Script Date: 23-Mar-16 5:01:22 PM ******/ | |
SET ANSI_NULLS ON | |
GO | |
SET QUOTED_IDENTIFIER ON | |
GO |