public async Task OnGetAsync(Guid courseId) { Record = new Record { CourseId = courseId }; var course = (await store.FindAsync <Course>(x => x.Id == courseId)).FirstOrDefault(); if (course is null) { RedirectToPage("/ChooseCourse"); return; } Students = (await store.FindAsync <Student>(x => x.ClassId == course.ClassId)).ToList(); var itms = (await store.FindAsync <Record>(x => x.CourseId == courseId)).ToList(); Records = new List <RecordViewModel>(); itms.ForEach(x => Records.Add(new RecordViewModel { Exam = x.Exam, CourseId = x.CourseId, Course = course, FirstAssignment = x.FirstAssignment, FirstTest = x.FirstTest, Id = x.Id, SecondAssignment = x.SecondAssignment, SecondTest = x.SecondTest, StudentId = x.StudentId, Student = Students.FirstOrDefault(y => y.Id == x.StudentId) })); }
public async Task OnGetAsync(Guid id) { Student = (await store.FindAsync <Student>(x => x.Id == id)).FirstOrDefault(); if (Student is null) { RedirectToPage("ChooseStudent"); return; } var courses = (await store.FindAsync <Course>(x => x.ClassId == Student.ClassId)).ToList(); var records = (await store.FindAsync <Record>(x => x.StudentId == Student.Id)).ToList(); Records = new List <RecordViewModel>(); records.ForEach(x => Records.Add(new RecordViewModel { CourseId = x.CourseId, Exam = x.Exam, FirstAssignment = x.FirstAssignment, FirstTest = x.FirstTest, Id = x.Id, SecondAssignment = x.SecondAssignment, SecondTest = x.SecondTest, Student = Student, StudentId = x.StudentId, Course = courses.FirstOrDefault(y => y.Id == x.CourseId) })); }
public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } var item = (await store.FindAsync <Student>(x => x.Fullname.ToLower() == Name.ToLower())).FirstOrDefault(); if (item is null) { return(Page()); } // await store.InsertAsync(Class); return(RedirectToPage("/StudentRecord", new { item.Id })); }