public void GetAuditableAbsenceTest()
        {
            DbContextHelper.Init(typeof(CourseDbContext), GlobalSettings.DATABASE.ConnectionString, 8);

            AbsenceRepository repo = new AbsenceRepository();
            //Assert.AreEqual(1, repo.GetAuditableAbsence(1).Count);
        }
        public void GetAllChangeableAbsenceTest2()
        {
            DbContextHelper.Init(typeof(CourseDbContext), GlobalSettings.DATABASE.ConnectionString, 8);

            AbsenceRepository repo = new AbsenceRepository();
            //var result = new AbsenceView().Show(repo.GetAllChangeableAbsence(1));
        }
        public void DestroyTest()
        {
            DbContextHelper.Init(typeof(CourseDbContext), GlobalSettings.DATABASE.ConnectionString, 8);

            AbsenceRepository repo = new AbsenceRepository();
            //Assert.AreEqual(true, repo.Destroy(1, 1));
        }
        public void CreateTest()
        {
            DbContextHelper.Init(typeof(CourseDbContext), GlobalSettings.DATABASE.ConnectionString, 8);

            AbsenceRepository repo = new AbsenceRepository();
            //Assert.AreEqual(true, repo.Create("I'm gonna to sleep...", 1, 1));
        }
        /// <summary>
        /// Get all of attendances status of the user
        /// </summary>
        /// <returns></returns>
        public string Index()
        {
            AbsenceRepository absenceRepo = new AbsenceRepository();
            var result = absenceRepo.GetAll(Auth.User().Id);

            return resultSetView.Show(result);
        }
        /// <summary>
        /// Record a student who absent on the course
        /// </summary>
        /// <param name="type"></param>
        /// <param name="studentId"></param>
        /// <param name="dispatchId"></param>
        /// <returns></returns>
        public string AddStudentAbsence(string type, int studentId, int dispatchId)
        {
            Validator validator = new Validator();
            // Validate the user input here.
            if (!validator.Make(new string[] { type, studentId + "", dispatchId + "" },
                new string[] { "required", "required", "required" },
                new string[] { "type", "studentId", "dispatchId" }))
            {
                return resultSetView.Error(validator.GetDetail());
            }

            AbsenceRepository absenceRepo = new AbsenceRepository();

            bool ret = absenceRepo.AddStudentAbsence(type, studentId, dispatchId, Auth.User().Id);

            return ret ? resultSetView.Success() : resultSetView.Error();
        }