public async Task <ZombieSighting> BiteHuman() { ZombieSighting ret = await RunAsync(); _persistencyLayer.AddZombie(ret); return(ret); }
public void Add(ZombieSighting zombie) { using (var db = new ZombieContext()) { db.ZombieSightings.Add(zombie); db.SaveChanges(); } }
async Task <ZombieSighting> RunAsync() { ZombieSighting zombieSighting = null; using (var client = new HttpClient()) { client.BaseAddress = new Uri("http://localhost:56085/"); client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); client.DefaultRequestHeaders.Add("BGT-CorrelationId", (string)this.ControllerContext.Request.Properties["BGT-CorrelationId"]); // HTTP GET HttpResponseMessage response = await client.GetAsync("api/human/bite"); if (response.IsSuccessStatusCode) { zombieSighting = await response.Content.ReadAsAsync <ZombieSighting>(); Console.WriteLine("{0}\t${1}\t{2}", zombieSighting.Name, zombieSighting.Latitude, zombieSighting.Longitude); } } return(zombieSighting); }
public HttpResponseMessage Add([FromBody] ZombieSighting zombie) { _persistencyLayer.AddZombie(zombie); return(new HttpResponseMessage(HttpStatusCode.Accepted)); }
public void AddZombie(ZombieSighting zombie) { _zombiePersistency.Add(zombie); }