public static async Task <PrisonerModel> LoadPrisonerByID(int id) { var uri = $"http://localhost:49574/api/prisoner/gbid/{ id }/"; using (HttpResponseMessage responseMessage = await ApiHelper.MyApiClient.GetAsync(uri)) { if (responseMessage.IsSuccessStatusCode) { PrisonerModel prisoner = await responseMessage.Content.ReadAsAsync <PrisonerModel>(); return(prisoner); } else { throw new Exception(responseMessage.ReasonPhrase); } } }
public static async Task <HttpStatusCode> InsertPrisoner(string fname, string lname) { var uri = "http://localhost:49574/api/prisoner/postprisoner"; var data = new PrisonerModel() { ID = 0, FirstName = fname, LastName = lname, }; using (HttpResponseMessage responseMessage = await ApiHelper.MyApiClient.PostAsJsonAsync(uri, data)) { if (responseMessage.IsSuccessStatusCode) { return(responseMessage.StatusCode); } else { throw new Exception(responseMessage.ReasonPhrase); } } }
public void PostPrisoner([FromBody] PrisonerModel model) { //prisoners.Add(value); MySqlDataAccess.CreatePrisoner(model.FirstName, model.LastName); }