public IActionResult AddAnAbsense(AttendanceInputViewModel input)
        {
            bool isItNull  = false;
            int  studentId = this.GetRouteId();

            input.StudentId = studentId;
            input.Student   = this.studentsService.GetStudentById(studentId);

            if (input.SubjectId == null)
            {
                input.SubjectId = 1;
                isItNull        = true;
            }

            //if (!this.ModelState.IsValid)
            //{
            //    int student_Id = this.GetRouteId();
            //    var subjects = this.studentSubjectsService.GetAllSubjectsByStudentId<SubjectDropDownListViewModel>(student_Id);
            //    input.Subjects = subjects;

            //    return this.View(input);
            //}

            var student = this.studentsService.GetStudentById(studentId);

            input.Student   = student;
            input.StudentId = student.Id;

            Attendance attendance = new Attendance();

            if (isItNull == false)
            {
                int?subjectId = input.SubjectId;
                var subject   = this.subjectsService.GetById((int)subjectId);

                input.Subject   = subject;
                input.SubjectId = subject.Id;

                attendance = this.attendancesService.CreateAttendance(input.Subject, input.Student, input.DateOfAbsense, input.Remark);
            }
            else
            {
                attendance.Student       = student;
                attendance.StudentId     = student.Id;
                attendance.Subject       = null;
                attendance.SubjectId     = null;
                attendance.DateOfAbsense = input.DateOfAbsense;
                attendance.Remark        = input.Remark;
            }

            using (this.db)
            {
                this.db.Attendances.Add(attendance);
                this.db.SaveChanges();
            }

            return(this.RedirectToAction("Info", "Student", new { id = student.Id }));
        }
        public IActionResult AddAnAbsense()
        {
            int studentId = this.GetRouteId();

            var subjects = this.studentSubjectsService.GetAllSubjectsByStudentId <SubjectDropDownListViewModel>(studentId);
            var input    = new AttendanceInputViewModel
            {
                StudentId = studentId,
                Subjects  = subjects,
            };

            return(this.View(input));
        }