public IActionResult Create(CreateExerciseViewModel model) { var user = userManager.GetUserAsync(HttpContext.User).Result; if (ModelState.IsValid) { var course = courseManager.GetById(model.CourseId); ExerciseDTO task = new ExerciseDTO { CourseId = model.CourseId, Course = course.Name, TaskName = model.TaskName, TaskTextField = model.TaskTextField, TaskBaseCodeField = model.TaskBaseCodeField, TestCasesCode = model.TestCases, TeacherId = user.Id, Rating = 0, CreateDateTime = DateTime.Now, UpdateDateTime = DateTime.Now }; exerciseManager.Insert(task); } return(RedirectToAction("Index", "ExerciseManagement")); }