public IActionResult Create([FromBody] Exam exam) { if (exam == null) { return(BadRequest()); } try { _logger.LogInformation("Create new exam in the database."); examService.CreateExam(exam); _logger.LogInformation($"Exam has been created."); return(RedirectToAction("Index")); } catch (SqlException ex) { _logger.LogError($"Something went wrong SQL: {ex}"); return(StatusCode(500, "Internal server error. Element not created.")); } catch (Exception ex) { _logger.LogError($"Something went wrong: {ex}"); return(StatusCode(500, "Internal server error.")); } }