Ejemplo n.º 1
0
        public async Task <IActionResult> Create()
        {
            var schoolId = await this.userService.GetSchoolIdForUser(UserId);

            var students = await this.studentService.GetAll(schoolId);

            var model = new ParentCreateViewModel
            {
                Students = students,
            };

            return(View(nameof(Create), model));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Create(ParentCreateViewModel model)
        {
            var schoolId = await this.userService.GetSchoolIdForUser(UserId);

            model.SchoolId = schoolId;

            if (!ModelState.IsValid)
            {
                return(View(nameof(Create)));
            }

            var user = await this.userService.Create(model);

            await this.parentService.EditParentStudents(user.Id, model.StudentIds);

            return(await Index());
        }