public async Task AddParent(AddParentInputModel input) { Student student = this.studentsRepository.All().FirstOrDefault(s => s.Id == input.StudentId); student.ParentId = input.ParentId; await this.studentsRepository.SaveChangesAsync(); }
public IActionResult AddParent() { AddParentInputModel input = new AddParentInputModel { Students = this.studentsService.GetAllAsSelectListItems(), Parents = this.parentsService.GetAllAsSelectListItems(), }; return(this.View(input)); }
public async Task <IActionResult> AddParent(AddParentInputModel input) { if (!this.ModelState.IsValid) { input.Students = this.studentsService.GetAllAsSelectListItems(); input.Parents = this.parentsService.GetAllAsSelectListItems(); return(this.View(input)); } await this.studentsService.AddParent(input); this.TempData["Message"] = "Successfully added/edited parent for student!"; return(this.Redirect("/")); }