public async Task <IActionResult> Edit(StudentEditInputModel model)
        {
            if (this.ModelState.IsValid)
            {
                StudentServiceModel serviceModel = model.To <StudentServiceModel>();

                bool result = await this.studentService.EditStudentAsync(serviceModel);

                if (result)
                {
                    return(this.RedirectToAction("All"));
                }
            }

            var studentClass = await this.classService.GetStudentClassDropdownAsync(model.Id);

            this.ViewBag.StudentClass = studentClass;

            return(this.View(model));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> EditStudent(StudentEditInputModel model)
        {
            if (this.ModelState.IsValid)
            {
                var serviceModel = model.To <StudentServiceModel>();

                var result = await this.studentService.EditStudentAsync(serviceModel);

                if (result)
                {
                    return(this.RedirectToAction("StudentsAll", new { id = model.ClassId }));
                }
            }

            string classFullName = await this.classService.GetClassNameByIdAsync(model.ClassId);

            string classId = model.ClassId;

            this.ViewBag.ClassName = classFullName;
            this.ViewBag.ClassId   = classId;

            return(this.View(model));
        }