private async Task <ResponseService.Result> APIsValid(string apiKey, string apiUrl, string requestBody) { var rs = new ResponseService(); ResponseService.Result result = await rs.InvokeRequestResponseService(apiKey, apiUrl, requestBody); return(result); }
public async Task <IActionResult> Edit(Guid id, [Bind("StudentId,APIKey,APIUrl,ASUStudentId,DateCreated,DateModified,FirstName,LastName,RequestBody")] Student student) { if (id != student.StudentId) { return(NotFound()); } if (ModelState.IsValid) { try { ResponseService.Result result = await APIsValid(student.APIKey, student.APIUrl, student.RequestBody); student.APIIsValid = result.IsValid; student.APIResponse = result.ResponseContent; student.DateModified = DateTime.Now; _context.Update(student); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!StudentExists(student.StudentId)) { return(NotFound()); } else { throw; } } // Show msg based on api result var msg = "fail"; if (student.APIIsValid == true) { msg = "success"; } return(RedirectToAction("Edit", new { msg = msg })); } return(View(student)); }