public void Post() { var munch = new MunchModel { PlayerName = "Kocham Alunię, bo jest śliczna! :*:*", LifeCount = 1 }; client.PostAsync <MunchModel>(baseUrl, munch, formatter.First()) .ContinueWith(PostAsyncTask()) .Wait(); }
public void Get() { MunchModel munch = null; int id = 1; baseUrl += id.ToString(); client.GetAsync(baseUrl) .ContinueWith(t => { HttpResponseMessage response; response = t.Result; response.EnsureSuccessStatusCode(); var readTask = response.Content.ReadAsAsync <MunchModel>(); readTask.Wait(); munch = readTask.Result; }) .Wait(); Assert.IsNotNull(munch); }
public IEnumerable <MunchModel> AddMunch(MunchModel munch) { _db.Munches.Add(munch); _db.SaveChanges(); return(_db.Munches); }
// POST api/munch public HttpResponseMessage Post([FromBody] MunchModel munch) { return(_munchService.AddMunch(munch).PostResponseMessage(munch, Request)); }