public ActionResult ViewAttendance()
        {
            DBSmartSchoolWebPortalEntities111 db = new DBSmartSchoolWebPortalEntities111();
            var studentId      = db.Parents.Where(x => x.Id == LoginClass.LoginId).First();
            var AttendanceList = db.StudentAttendances.Where(x => x.StudentId == studentId.StudentId).ToList();
            List <StudentAttendanceViewModel> PassList = new List <StudentAttendanceViewModel>();

            foreach (var i in AttendanceList)
            {
                StudentAttendanceViewModel att = new StudentAttendanceViewModel();
                var classattendance            = db.ClassAttendances.Where(x => x.Id == i.ClassAttendanceId).First();
                att.Date = Convert.ToDateTime(classattendance.Date);
                if (i.Status == 1)
                {
                    att.Status = "Present";
                }
                else if (i.Status == 2)
                {
                    att.Status = "Absent";
                }
                else if (i.Status == 3)
                {
                    att.Status = "Leave";
                }
                else
                {
                    att.Status = "Late";
                }

                PassList.Add(att);
            }
            return(View(PassList));
        }
        public IEnumerable <StudentAttendanceViewModel> GetByStudent(StudentViewModel student)
        {
            var records  = new List <StudentAttendanceViewModel>();
            var offereds = OfferedRepository.GetByStudentID(student.StudentId);

            if (offereds != null)
            {
                foreach (var offered in offereds)
                {
                    attendance_block block = Context.attendance_block
                                             .Where(w => w.BeginDate == offered.StartDate)
                                             .FirstOrDefault();

                    if (block == null)
                    {
                        continue;
                    }

                    var sessions = block.attendance_session
                                   .Where(w => w.TimeslotId == "AM")
                                   .ToList().Select(s => new SessionViewModel(s)).ToList();

                    var studentAttendanceViewModel = new StudentAttendanceViewModel();
                    studentAttendanceViewModel.Student           = student;
                    studentAttendanceViewModel.CourseOffered     = offered;
                    studentAttendanceViewModel.Sessions          = sessions;
                    studentAttendanceViewModel.AttendanceRecords = GetAttendanceRecords(student.Barcode, block.BeginDate, block.EndDate);
                    records.Add(studentAttendanceViewModel);
                }
            }

            return(records);
        }
        public ActionResult ShowFromTo(StudentAttendanceViewModel stdAttend)
        {
            //string validformats =  "MM/dd/yyyy";

            //CultureInfo provider = new CultureInfo("en-US");

            var departments = db.Department.ToList();
            //need modification to datetime

            List <Attendance> attends = db.Attendance.Include(a => a.User)
                                        .Where(a => a.AttDate >= stdAttend.From && a.AttDate <= stdAttend.To && a.User.DeptId == stdAttend.Student.DeptId).ToList();

            var AttResult = from student in attends group student by student.User.UserName;

            var permission = db.Permission.Include(p => p.User)
                             .Where(p => p.PermDate >= stdAttend.From && p.PermDate <= stdAttend.To)
                             .ToList();

            var PermResult = from student in permission group student by student.User.UserName;

            stdAttend.Attendances = AttResult;
            stdAttend.Departments = departments;
            stdAttend.Permission  = PermResult;

            return(View(stdAttend));
        }
 public IActionResult AttendanceStudent(decimal?stud, decimal?subj)
 {
     if (stud != null && subj != null)
     {
         var student  = db.Students.FirstOrDefault(s => s.AccountId == stud);
         var subject  = db.Subjects.FirstOrDefault(s => s.SubjectId == subj);
         var teacher  = CurrentUser;
         var journals = db.Journals.Where(j =>
                                          j.StudentAccountId == student.AccountId &&
                                          j.SubjectId == subject.SubjectId &&
                                          j.TeacherAccountId == teacher.AccountId
                                          );
         StudentAttendanceViewModel model = new StudentAttendanceViewModel
         {
             CurrentStudent = student,
             CurrentSubject = subject,
             Journals       = journals
         };
         return(View("AttendanceStudent", model));
     }
     else
     {
         return(RedirectToAction("Attendance"));
     }
 }
        public IEnumerable <StudentAttendanceViewModel> GetByCourse(OfferedViewModel offered)
        {
            var records = new List <StudentAttendanceViewModel>();
            var block   = Context.attendance_block
                          .Where(w => w.BeginDate == offered.StartDate)
                          .FirstOrDefault();

            if (block != null)
            {
                var sessions = block.attendance_session
                               .Where(w => w.TimeslotId == "AM")
                               .Select(s => new SessionViewModel(s)).ToList();

                foreach (var student in StudentRepository.GetByOfferedId(offered.Id))
                {
                    var studentAttendanceViewModel = new StudentAttendanceViewModel();
                    studentAttendanceViewModel.Student           = student;
                    studentAttendanceViewModel.CourseOffered     = offered;
                    studentAttendanceViewModel.Sessions          = sessions;
                    studentAttendanceViewModel.AttendanceRecords = GetAttendanceRecords(student.Barcode, block.BeginDate, block.EndDate);
                    records.Add(studentAttendanceViewModel);
                }
            }

            return(records);
        }
Beispiel #6
0
 public static Entities.Attendance MapStudentAttendanceViewModelToAttendance(StudentAttendanceViewModel studentAttendanceViewModel)
 {
     return(new Entities.Attendance()
     {
         Id = studentAttendanceViewModel.Id,
         Date = studentAttendanceViewModel.Date,
         IsPresent = studentAttendanceViewModel.IsPresent,
         IdStudent = studentAttendanceViewModel.IdStudent,
         IdClassRoom = studentAttendanceViewModel.IdClassRoom
     });
 }
Beispiel #7
0
        public ActionResult AddStudentAttendance(StudentAttendanceViewModel studentAttendanceViewModel)
        {
            if (ModelState.IsValid)
            {
                var attendance = Mapping.MapStudentAttendanceViewModelToAttendance(studentAttendanceViewModel);
                db.Attendances.Add(attendance);
                db.SaveChanges();
            }

            ListeAttendance();

            return(View(studentAttendanceViewModel));
        }
        public ActionResult GenerateReportAttendance()
        {
            DBSmartSchoolWebPortalEntities111 db = new DBSmartSchoolWebPortalEntities111();

            var AttendanceList = db.StudentAttendances.Where(x => x.StudentId == LoginClass.LoginId).ToList();
            List <StudentAttendanceViewModel> PassList = new List <StudentAttendanceViewModel>();

            foreach (var i in AttendanceList)
            {
                StudentAttendanceViewModel att = new StudentAttendanceViewModel();
                var classattendance            = db.ClassAttendances.Where(x => x.Id == i.ClassAttendanceId).First();
                att.Date = Convert.ToDateTime(classattendance.Date);
                if (i.Status == 1)
                {
                    att.Status = "Present";
                }
                else if (i.Status == 2)
                {
                    att.Status = "Absent";
                }
                else if (i.Status == 3)
                {
                    att.Status = "Leave";
                }
                else
                {
                    att.Status = "Late";
                }

                PassList.Add(att);
            }

            ReportDocument rd = new ReportDocument();

            rd.Load(Path.Combine(Server.MapPath("~/Reports"), "CrystalReportAttendance.rpt"));
            rd.SetDataSource(PassList);
            Response.Buffer = false;
            Response.ClearContent();
            Response.ClearHeaders();
            try
            {
                Stream stream = rd.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
                stream.Seek(0, SeekOrigin.Begin);
                return(File(stream, "application/pdf", "RegisteredCoursesList.pdf"));
            }
            catch
            {
                throw;
            }
        }
Beispiel #9
0
        public ActionResult Attendance()
        {
            var userId = User.Identity.GetUserId();

            if (userId == null || userId == "")
            {
                return(View());
            }

            var student  = _studentDataService.GetByUserId(userId);
            var group    = _groupDataService.GetByStudent(student.Id);
            var lectures = _lectureDataService.GetByGroupId(group.Id);

            var attendanceStats = new List <StudentAttendanceViewModel>();

            var generalStats = new StudentAttendanceViewModel
            {
                Subject               = "General",
                LectureCount          = _getOccurencesCount(lectures),
                AttendedLecturesCount = _getAttendedLecturesCount(lectures, student)
            };

            attendanceStats.Add(generalStats);

            foreach (var lecture in lectures)
            {
                var attended = _attendanceDataService.GetStudentAttendance(student.Id, lecture.Id);

                if (attendanceStats.Any(x => x.Subject == lecture.Subject.Name))
                {
                    attendanceStats.FirstOrDefault(x => x.Subject == lecture.Subject.Name).LectureCount          += lecture.Occurences.Count;
                    attendanceStats.FirstOrDefault(x => x.Subject == lecture.Subject.Name).AttendedLecturesCount +=
                        attended.AttendedLectures == "" ? 0 : attended.AttendedLectures.Split(',').Count();
                }
                else
                {
                    var stats = new StudentAttendanceViewModel
                    {
                        Subject               = lecture.Subject.Name,
                        LectureCount          = lecture.Occurences.Count,
                        AttendedLecturesCount = attended.AttendedLectures == "" ? 0 : attended.AttendedLectures.Split(',').Count()
                    };
                    attendanceStats.Add(stats);
                }
            }

            return(View(attendanceStats));
        }
        public IActionResult Attendance()
        {
            Student student  = CurrentUser;
            var     records  = db.Records.Where(r => r.StudentAccountId == student.AccountId);
            var     subjects = db.Subjects.Where(s => records.FirstOrDefault(r => r.SubjectId == s.SubjectId) != null);

            StudentAttendanceViewModel model = new StudentAttendanceViewModel
            {
                CurrentStudent = student,
                CurrentSubject = null,
                Records        = records,
                Subjects       = subjects,
                Journals       = null,
                Teachers       = null
            };

            return(View("Attendance", model));
        }
        public ActionResult DetailStudentAttendance(int id)
        {
            StudentAttendanceViewModel studentAttendances = new StudentAttendanceViewModel()
            {
                Id        = id,
                Date      = DateTime.Now,
                IsPresent = true,
                Student   = new StudentViewModel()
                {
                    Id = 1, Name = "jonathan"
                },
                IdClassRoom   = 5,
                ClassRoomName = "toto"
            };

            ViewBag.Message = "Detail Student Attendance";

            return(View());
        }
Beispiel #12
0
        public static Attendance MapToAttendance(this StudentAttendanceViewModel studentAttendanceVM)
        {
            var Attendance = new Attendance();

            if (studentAttendanceVM == null)
            {
                return(Attendance);
            }

            Attendance = new Attendance()
            {
                Id          = studentAttendanceVM.Id,
                Date        = studentAttendanceVM.Date,
                IsPresent   = studentAttendanceVM.IsPresent,
                IdStudent   = studentAttendanceVM.Student.Id,
                IdClassRoom = studentAttendanceVM.IdClassRoom,
            };
            return(Attendance);
        }
        public IActionResult Attendance(StudentAttendanceViewModel model)
        {
            Student student = CurrentUser;
            Subject subject = db.Subjects.FirstOrDefault(s => s.SubjectId == model.CurrentSubjectId);

            var records  = db.Records.Where(r => r.StudentAccountId == student.AccountId);
            var subjects = db.Subjects.Where(s => records.FirstOrDefault(r => r.SubjectId == s.SubjectId) != null);
            var journals = db.Journals.Where(j => j.SubjectId == subject.SubjectId && j.StudentAccountId == student.AccountId);
            var teachers = db.Teachers.Where(t => journals.FirstOrDefault(j => j.TeacherAccountId == t.AccountId) != null);

            model.CurrentStudent = student;
            model.CurrentSubject = subject;
            model.Records        = records;
            model.Subjects       = subjects;
            model.Journals       = journals;
            model.Teachers       = teachers;

            return(View("Attendance", model));
        }
Beispiel #14
0
        public StudentAttendanceViewModel GetByStudentCourse(StudentViewModel student, OfferedViewModel offered)
        {
            var record = new StudentAttendanceViewModel();

            attendance_block block = Context.attendance_block
                                     .Where(w => w.BeginDate == offered.StartDate)
                                     .FirstOrDefault();

            if (block != null)
            {
                var sessions = block.attendance_session.Where(w => w.TimeslotId == "AM").ToList().Select(s => new SessionViewModel(s)).ToList();

                record.Student           = student;
                record.CourseOffered     = offered;
                record.Sessions          = sessions;
                record.AttendanceRecords = GetAttendanceRecords(student.Barcode, block.BeginDate, block.EndDate);
            }

            return(record);
        }
Beispiel #15
0
        public ActionResult RollAttendance(int RollCallID, int StudentID)
        {
            Student  Stu  = StuBO.GetStudentByID(StudentID);
            RollCall Roll = RollBO.GetRollCallByID(RollCallID);

            AttendanceBusiness   AttenBO      = new AttendanceBusiness();
            List <AttendanceLog> RollCallLogs = AttenBO.GetRollCallAttendanceLog(RollCallID);

            //Tim nhung attendance cua student, nam trong log, co rollcallID bang RollcallID dua vao
            var StudentAttendances = Stu.StudentAttendances.Where(sa => sa.AttendanceLog.RollCallID == RollCallID &&
                                                                  RollCallLogs.Select(r => r.LogID).Contains(sa.LogID))
                                     .OrderBy(sa => sa.AttendanceLog.LogDate).ToList();


            StudentAttendanceViewModel Model = new StudentAttendanceViewModel();

            Model.InStudent          = Stu;
            Model.InRollCall         = Roll;
            Model.StudentAttendances = StudentAttendances;

            return(PartialView("_RollAttendance", Model));
        }
Beispiel #16
0
        public static StudentAttendanceViewModel MapToStudentAttendanceViewModel(this Attendance attendance)
        {
            var studentAttendanceVM = new StudentAttendanceViewModel();

            if (attendance == null)
            {
                return(studentAttendanceVM);
            }

            studentAttendanceVM = new StudentAttendanceViewModel()
            {
                Id        = attendance.Id,
                Date      = attendance.Date,
                IsPresent = attendance.IsPresent,
                Student   = attendance.Student.MapToStudentViewmodel(), // Student can call MaptoStudentviewmodel because of "this student" : méthode d'extension.
                //Student = MapToStudentViewmodel(attendance.Student), // We can do it too !!
                IdClassRoom   = attendance.IdClassRoom,
                ClassRoomName = attendance.ClassRoom.Name
            };

            return(studentAttendanceVM);
        }
        public ActionResult ShowFromTo()
        {
            var departments = db.Department.ToList();

            List <Attendance> attends = db.Attendance.Include(a => a.User).ToList();

            //List<AttendInfo> attends =
            //            (from ep in db.Attendance
            //             join e in db.Users on ep.StdId equals e.Id
            //             join t in db.Permission on e.Id equals t.StdId
            //             select (new AttendInfo
            //             {
            //                 Attendances = ep,
            //                 Permissions = t,
            //                 Students = e
            //             })).ToList();


            var AttResult = from student in attends group student by student.User.UserName;

            var permission = db.Permission.Include(p => p.User).ToList();

            var PermResult = from student in permission group student by student.User.UserName;

            //// Common Keys between left and right
            //var r = result.Where(s => result.Select(p => p.Key ).Contains(s.Key)).ToList();

            var viewModel = new StudentAttendanceViewModel
            {
                Departments = departments
                ,
                Attendances = AttResult
                ,
                Permission = PermResult
            };

            return(View(viewModel));
        }
 public StudentAttendanceReport()
 {
     InitializeComponent();
     DataContext = new StudentAttendanceViewModel(this);
     (DataContext as StudentAttendanceViewModel)._view = this as StudentAttendanceReport;
 }