public ActionResult Create(ManageTrainee manageTrainee) { if (!ModelState.IsValid) { return(View("~/Views/ErrorValidations/Null.cshtml")); } var checkTraineeInCourse = _context.ManageTrainees.Any(c => c.TraineeId == manageTrainee.TraineeId && c.CourseId == manageTrainee.CourseId); if (checkTraineeInCourse == true) { return(View("~/Views/ErrorValidations/Exist.cshtml")); } var newTrainee = new ManageTrainee { TraineeId = manageTrainee.TraineeId, CourseId = manageTrainee.CourseId }; _context.ManageTrainees.Add(newTrainee); _context.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Create(ManageTrainee manageTrainee) { var newTrainee = new ManageTrainee { TraineeId = manageTrainee.TraineeId, CourseId = manageTrainee.CourseId }; _context.ManageTrainees.Add(newTrainee); _context.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Create(Topic topic) { ManageTrainee manageTrainee = new ManageTrainee { TraineeId = User.Identity.GetUserId(), TopicId = topic.Id }; _context.ManageTrainees.Add(manageTrainee); _context.SaveChanges(); return(RedirectToAction("Index")); }