public IActionResult GetScheduleOnWeek(string studentId, DateTime date)
        {
            CheckValid valid = new CheckValid();

            try
            {
                if (!valid.IsExistedStudentId(studentId))
                {
                    valid.IsValid = false;
                }
                if (valid.StringIsNullOrEmpty(date.ToString()))
                {
                    valid.IsValid = false;
                }

                if (valid.IsValid)
                {
                    var listClassSubject = GetClassSubjectByStudentId(studentId);

                    if (listClassSubject != null)
                    {
                        Dictionary <string, Object> dicClassSubjectSchedule = new Dictionary <string, object>();

                        var mondayInWeek = date.StartOfWeek(DayOfWeek.Monday);

                        var sundayInWeek = mondayInWeek.AddDays(6.0);

                        foreach (var classSubject in listClassSubject)
                        {
                            var ds = GetScheduleByClassSubjectId(classSubject.Id);

                            var scheduleOfClassSubject = GetScheduleByClassSubjectId(classSubject.Id).Where(x => x.Date >= mondayInWeek && x.Date <= sundayInWeek).ToList();

                            foreach (var schedule in scheduleOfClassSubject)
                            {
                                string s = $"{schedule.Date.DayOfWeek.ToString()}/{schedule.Slot}";

                                int a = schedule.ClassSubjectSchedule.ToList()[0].Id;

                                var attendance = GetAttendance(studentId, schedule.ClassSubjectSchedule.ToList()[0].Id,
                                                               classSubject.Id);

                                dicClassSubjectSchedule.Add(s, new
                                {
                                    subject = classSubject.SubjectId,
                                    classId = classSubject.ClassId,
                                    atten   = attendance.Attendance
                                });
                            }
                        }

                        if (dicClassSubjectSchedule.Count > 0)
                        {
                            return(Ok(new BaseResponse(dicClassSubjectSchedule, "Success with schedule", true)));
                        }

                        return(Ok(new BaseResponse(dicClassSubjectSchedule, "Success but not have any schedule on this week", true)));
                    }

                    return(NotFound(new BaseResponse(null, "Student is not study any subject", false)));
                }

                return(NotFound(new BaseResponse(null, valid.ErrorMessage, false)));
            }
            catch (Exception e)
            {
                return(BadRequest(new BaseResponse(null, e.Message, false)));
            }
        }
        public IActionResult UpdateAttendance(string studentId, bool attendance)
        {
            CheckValid valid       = new CheckValid();
            var        timeRequest = DateTime.Now;
            var        slotJoin    = getSlot(timeRequest);
            var        check       = false;

            try
            {
                if (!valid.IsExistedStudentId(studentId))
                {
                    valid.IsValid = false;
                }
                if (valid.StringIsNullOrEmpty(attendance.ToString()))
                {
                    valid.IsValid = false;
                }

                if (valid.IsValid)
                {
                    var listClassSubject = GetClassSubjectByStudentId(studentId);

                    if (listClassSubject.Count > 0)
                    {
                        foreach (var classSubject in listClassSubject)
                        {
                            var ListSchedule = GetScheduleByClassSubjectId(classSubject.Id).Where(x => x.Date == timeRequest.Date);
                            foreach (var schedule in ListSchedule)
                            {
                                if (schedule.Slot == slotJoin)
                                {
                                    var context = new FaceIOContext();
                                    var classSubjectSchedule = context.ClassSubjectSchedule.Where(x =>
                                                                                                  x.ClassSubjectId == classSubject.Id && x.ScheduleId == schedule.Id).FirstOrDefault();

                                    var studentStudyAttendance =
                                        context.StudentStudyAttendance.Where(x =>
                                                                             x.ClassSubjectScheduleId == classSubjectSchedule.Id).FirstOrDefault();

                                    if (studentStudyAttendance != null)
                                    {
                                        studentStudyAttendance.Attendance = true;

                                        context.StudentStudyAttendance.Update(studentStudyAttendance);

                                        context.SaveChanges();

                                        check = true;
                                        break;
                                    }
                                }

                                else
                                {
                                    continue;
                                }
                            }

                            if (check)
                            {
                                break;
                            }
                        }

                        if (check == false)
                        {
                            return(NotFound(new BaseResponse(null, "Attendance failed", false)));
                        }
                        else
                        {
                            return(Ok(new BaseResponse(null, "Update attendance success", true)));
                        }
                    }

                    return(NotFound(new BaseResponse(null, "Not found any subject by student ID", false)));
                }

                return(NotFound(new BaseResponse(null, valid.ErrorMessage, false)));
            }
            catch (Exception e)
            {
                return(BadRequest(new BaseResponse(null, e.Message, false)));
            }
        }