Example #1
0
        /// <summary>
        /// Remove a absence record which has not been apply yet
        /// </summary>
        /// <returns></returns>
        public string Destroy(int id)
        {
            Validator validator = new Validator();
            if (!validator.MatchRule(id.ToString(), "required", "reasonId"))
            {
                return absenceView.Error(validator.GetDetail());
            }

            bool ret = absenceReasonRepo.Destroy(id, Auth.User().Id);

            return ret ? absenceView.Success() : absenceView.Error();
        }
        public string AllUser(int mode)
        {
            Validator validator = new Validator();
            if (! validator.MatchRule(mode + "", "required", "mode"))
            {
                return view.Error(validator.GetDetail());
            }

            var result = userRepo.GetAllUserByMode(mode);

            return view.Show(result);
        }
        public string Destroy(int id)
        {
            Validator validator = new Validator();
            // Validate the user input here.
            // Validate the user input here.
            if (!validator.MatchRule(id + "", "required", "id"))
            {
                return resultSetView.Error(validator.GetDetail());
            }

            bool ret = attendanceRepo.Destroy(id, Auth.User().Id);
            return ret ? resultSetView.Success() : resultSetView.Error();
        }
Example #4
0
        public string CreateDispatch(int id)
        {
            GenericView view = new GenericView();
            DispatchRepository dispatchRepo = new DispatchRepository();

            Validator validator = new Validator();
            if (!validator.MatchRule(id + "", "required", "id"))
            {
                return view.Error(validator.GetDetail());
            }

            bool Ret = dispatchRepo.JoinCourse(Auth.User().Id, id);

            return Ret ? view.Success() : view.Error();
        }
Example #5
0
        public string RemoveDispatch(string id)
        {
            GenericView view = new GenericView();
            DispatchRepository dispatchRepo = new DispatchRepository();

            Validator validator = new Validator();
            if (!validator.MatchRule(id, "required", "id"))
            {
                return view.Error(validator.GetDetail());
            }

            string[] idArr = id.Split(',');
            bool Ret = dispatchRepo.RemoveCourseList(Auth.User().Id, Array.ConvertAll(idArr, int.Parse));

            return Ret ? view.Success() : view.Error();
        }
Example #6
0
        public string OnLogin(string email, string pass, int mode)
        {
            LoginView view = new LoginView();
            Validator validator = new Validator();

            // Validate the user input here.
            if (!validator.MatchRule(email, "email", "email") )
            {
                return view.Error(validator.GetDetail());
            }

            UserRepository userRepo = new UserRepository();
            if (userRepo.Login(email, pass, mode))
            {
                return view.Show(userRepo.SessionId);
            }

            return view.Error();
        }