public async Task <IActionResult> Delete(int id) { IActionResult result = View(); using (var httpClient = ClientFactory.CreateClient("GeorestApi")) { try { var georestClient = new GeorestClient(httpClient.BaseAddress.ToString(), httpClient); int?studentId = (await georestClient.GetStudentLabByIdAsync(id).ConfigureAwait(false)).StudentId; await georestClient.DeleteStudentLabAsync(id); result = RedirectToAction(nameof(Index), studentId); } catch (SwaggerException se) { ModelState.AddModelError("", se.Message); } } return(result); }