// To protect from overposting attacks, please enable the specific properties you want to bind to, for // more details see https://aka.ms/RazorPagesCRUD. public async Task <IActionResult> OnPostAsync() { if (ModelState.IsValid) { string role = Summoner.Role; string url = baseUrl + "summoner/v4/summoners/by-name/" + Summoner.name + "?api_key=" + apikey; var request = new HttpRequestMessage(HttpMethod.Get, url); var client = _clientFactory.CreateClient(); var response = await client.SendAsync(request); if (response.IsSuccessStatusCode) { var json = await response.Content.ReadAsStringAsync(); Summoner = JsonConvert.DeserializeObject <Summoner>(json); Summoner.Role = role; Summoner.TeamID = id; } _context.Summoner.Add(Summoner); await _context.SaveChangesAsync(); return(RedirectToPage("/Teams/Index")); } else { return(Page()); } }
// To protect from overposting attacks, please enable the specific properties you want to bind to, for // more details see https://aka.ms/RazorPagesCRUD. public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } _context.Attach(VersusTeam).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!VersusTeamExists(VersusTeam.Id)) { return(NotFound()); } else { throw; } } return(RedirectToPage("./Index")); }
// To protect from overposting attacks, please enable the specific properties you want to bind to, for // more details see https://aka.ms/RazorPagesCRUD. public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } _context.VersusTeam.Add(VersusTeam); await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } Team = await _context.Team.FindAsync(id); if (Team != null) { _context.Team.Remove(Team); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync(string id) { if (id == null) { return(NotFound()); } Summoner = await _context.Summoner.FindAsync(id); if (Summoner != null) { _context.Summoner.Remove(Summoner); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }