Example #1
0
 public List <Subject> GetSubjectsModel()
 {
     try {
         List <Subject> subjects = subjectService.GetAllSubjects().ToList();
         return(subjects);
     }
     catch (Exception ex) {
         _logger.LogError($"Something went wrong: {ex}");
         return(null);
     }
 }
Example #2
0
        public JsonResult AjaxMethod()
        {
            List <Subject> data = new List <Subject>();

            try {
                data = subjectService.GetAllSubjects().ToList();
                return(Json(data));
            }
            catch (Exception ex)
            {
                _logger.LogError($"Something went wrong: {ex}");
                return(Json(new { message = "Internal server error." }));
            }
        }