public async Task <ActionResult> Create(IFormCollection formcollection, [Bind("Birthday,Email,Name,Gender, Password,EducationId")] Student student) { if (ModelState.IsValid) { try { // TODO: Add insert logic here Student result = await studentRepo.Create(student); logger.LogWarning(LogEventIds.InsertLogId, "student {name} toegevoegd met ID {Id}", result.Name, result.Id); logger.LogInformation(LogEventIds.InsertLogId, "Student {Name }toegevoegd met ID: {ID}", student.Name, student.Id); if (result == null) { throw new Exception(); } return(RedirectToAction(nameof(IndexAsync))); } catch (Exception ex) { logger.Log(LogLevel.Information, 0, typeof(Person), null, (type, exception) => "Hello from logger"); logger.LogInformation("User {userName} entered at {entryTime}", student.Name, DateTime.Now); logger.LogWarning(LogEventIds.InsertLogId, "er was geen {MODEL} aanwezig", student); ModelState.AddModelError("", "Create is unable to save." + ex); return(View()); } } else { return(View(student)); } }
public Student Create(StudentViewModel student) { Student new_Student = new Student() { F_Name = student.F_Name, L_Name = student.L_Name, E_mail = student.E_mail }; return(_studentRepo.Create(new_Student)); }