public async Task <Entity.Tournament> UpdateTournamentAsync(int id, Entity.Tournament tournament) { StringContent content = new StringContent(JsonConvert.SerializeObject(tournament), Encoding.UTF8, "application/json"); var result = await _httpClient.PutAsync("api/Tournaments/" + id, content); return(tournament); }
public async Task <Entity.Tournament> GetTournamentAsync(int id) { string result = await _httpClient.GetStringAsync("api/Tournaments/" + id); Entity.Tournament tournaments = JsonConvert.DeserializeObject <Entity.Tournament>(result); return(tournaments); }
public async Task <Entity.Tournament> AddTournamentAsync(Entity.Tournament tournament) { StringContent content = new StringContent(JsonConvert.SerializeObject(tournament), Encoding.UTF8, "application/json"); var result = await _httpClient.PostAsync("api/Tournaments", content); string Response = await result.Content.ReadAsStringAsync(); Entity.Tournament _tournament = JsonConvert.DeserializeObject <Entity.Tournament>(Response); return(_tournament); }
public async Task <ActionResult> Create(Entity.Tournament tournament) { try { var tournaments = await _serviceContext.AddTournamentAsync(tournament); return(RedirectToAction(nameof(Index))); } catch { return(View()); } }
public async Task <ActionResult> Edit(int id, Entity.Tournament tournament) { try { // TODO: Add update logic here var tournaments = await _serviceContext.UpdateTournamentAsync(id, tournament); return(RedirectToAction(nameof(Index))); } catch { return(View()); } }
public async Task <IActionResult> Put(Entity.Tournament value) { var result = await _repository.UpdateAsync(value); return(Ok(result)); }