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?instructorId = (await georestClient.GetInstructorLabByIdAsync(id).ConfigureAwait(false)).InstructorId; await georestClient.DeleteInstructorLabAsync(id); result = RedirectToAction(nameof(Index), instructorId); } catch (SwaggerException se) { ModelState.AddModelError("", se.Message); } } return(result); }