//[ValidateAntiForgeryToken] public async Task <IActionResult> Create(ReportNoteView reportNoteView) //[Bind("Id,Students,Tests,Note")] { var res = reportNoteView; ReportNote reportNote = new ReportNote { Student = this.repository.GetStudentId(reportNoteView.Student), Test = this.repository.GetTestId(reportNoteView.Test), Note = reportNoteView.Note }; if (ModelState.IsValid) { //Se valida que no repita el Test IEnumerable <ReportNote> report = this.repository.GetIdSumary(reportNote.Student.Id); var newTest = report.Where(r => r.Test.Id == reportNote.Test.Id).FirstOrDefault(); if (newTest == null) { this.repository.AddReportNote(reportNote); await repository.SaveAllAsync(); return(RedirectToAction(nameof(Index))); } } ViewBag.Message = "Test registered!"; reportNoteView.Tests = new SelectList(this.repository.GetTests(), "Id", "Name"); reportNoteView.Students = new SelectList(this.repository.GetStudents(), "Id", "Name"); return(View(reportNoteView)); }
// GET: ReportNotes/Create public IActionResult Create() { ReportNoteView model = new ReportNoteView(); model.Tests = new SelectList(this.repository.GetTests(), "Id", "Name"); model.Students = new SelectList(this.repository.GetStudents(), "Id", "Name"); return(View(model)); }