public async Task <IActionResult> PostStudentData(StudentModel studentModel) { RestMessage <StudentModel> response = new RestMessage <StudentModel>(); try { AuthenticationResult authenticationResult = await GetAuthenticationResult(); ServiceInterface serviceInterface = ServiceInterface.Instance; response = await serviceInterface.PostDataToAPI <StudentModel>(authenticationResult, "student", studentModel); if (!response.Success) { response.StatusText = "Error saving data"; } } catch (Exception e) { response.Exception = e; response.SetAsBadRequest(); response.StatusText = "Error saving data"; } return(Json(response)); }
public async Task <IActionResult> GetStudents() { RestMessage <List <StudentModel> > response = new RestMessage <List <StudentModel> >(); try { AuthenticationResult authenticationResult = await GetAuthenticationResult(); ServiceInterface serviceInterface = ServiceInterface.Instance; response = await serviceInterface.GetDataAsync <List <StudentModel> >(authenticationResult, "student"); if (!response.Success) { response.StatusText = "Error fetching Student data"; } } catch (Exception e) { response.Exception = e; response.SetAsBadRequest(); response.StatusText = "Error fetching Student data"; } return(Json(response)); }