public async Task <IActionResult> Index(int instructorId) { using (var httpClient = ClientFactory.CreateClient("GeorestApi")) { var georestClient = new GeorestClient(httpClient.BaseAddress.ToString(), httpClient); ViewBag.InstructorResponses = await georestClient.GetAllInstructorResponsesAsync(); } return(View()); }
public async Task <IActionResult> Index(int studentId) { using (var httpClient = ClientFactory.CreateClient("GeorestApi")) { var georestClient = new GeorestClient(httpClient.BaseAddress.ToString(), httpClient); ViewBag.StudentLabs = await georestClient.GetLabsForStudentAsync(studentId); } return(View()); }
public async Task <IActionResult> Index(int studentId) { using (var httpClient = ClientFactory.CreateClient("GeorestApi")) { var georestClient = new GeorestClient(httpClient.BaseAddress.ToString(), httpClient); ViewBag.StudentResponses = await georestClient.GetAllStudentResponsesAsync().ConfigureAwait(false); } return(View()); }
public async Task <IActionResult> Edit(int id) { InstructorResponseViewModel fetchedInstructorResponse = null; using (var httpClient = ClientFactory.CreateClient("GeorestApi")) { try { var georestClient = new GeorestClient(httpClient.BaseAddress.ToString(), httpClient); fetchedInstructorResponse = await georestClient.GetInstructorResponseByIdAsync(id); } catch (SwaggerException se) { ModelState.AddModelError("", se.Message); } } return(View(fetchedInstructorResponse)); }
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); await georestClient.DeleteInstructorResponseAsync(id); result = RedirectToAction(nameof(Index)); } catch (SwaggerException se) { ModelState.AddModelError("", se.Message); } } return(result); }
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); }
public async Task <IActionResult> Edit(InstructorResponseViewModel viewModel) { IActionResult result = View(); if (ModelState.IsValid) { using (var httpClient = ClientFactory.CreateClient("GeorestApi")) { try { var georestClient = new GeorestClient(httpClient.BaseAddress.ToString(), httpClient); await georestClient.UpdateInstructorResponseAsync((int)viewModel.Id, Mapper.Map <InstructorResponseInputViewModel>(viewModel)); result = RedirectToAction(nameof(Index)); } catch (SwaggerException se) { ModelState.AddModelError("", se.Message); } } } return(result); }
public async Task <IActionResult> Add(InstructorLabInputViewModel viewModel) { IActionResult result = View(); if (ModelState.IsValid) { using (var httpClient = ClientFactory.CreateClient("GeorestApi")) { try { var georestClient = new GeorestClient(httpClient.BaseAddress.ToString(), httpClient); await georestClient.AddInstructorLabAsync(viewModel); result = RedirectToAction(nameof(Index), viewModel.InstructorId); } catch (SwaggerException se) { ModelState.AddModelError("", se.Message); } } } return(result); }