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();
        }
예제 #2
0
        public IActionResult AddParent()
        {
            AddParentInputModel input = new AddParentInputModel
            {
                Students = this.studentsService.GetAllAsSelectListItems(),
                Parents  = this.parentsService.GetAllAsSelectListItems(),
            };

            return(this.View(input));
        }
예제 #3
0
        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("/"));
        }