当前位置: 首页>>代码示例>>C#>>正文


C# Validator.Make方法代码示例

本文整理汇总了C#中Validator.Make方法的典型用法代码示例。如果您正苦于以下问题:C# Validator.Make方法的具体用法?C# Validator.Make怎么用?C# Validator.Make使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Validator的用法示例。


在下文中一共展示了Validator.Make方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ResetPassword

        public string ResetPassword(int id, int mode)
        {
            Validator validator = new Validator();
            if (!validator.Make(new string[] { id + "", mode + "" },
                new string[] { "required", "required" },
                new string[] { "userId", "mode" }))
            {
                return view.Error(validator.GetDetail());
            }

            string pwd = Guard.GenerateRandomPassword();
            bool bRet = userRepo.ResetPassword(id, pwd, mode);

            return bRet ? view.Show(pwd) : view.Error();
        }
开发者ID:soxfmr,项目名称:CourseSystem,代码行数:15,代码来源:UserManagerController.cs

示例2: Destroy

        public string Destroy(int id, int mode)
        {
            Validator validator = new Validator();
            // Validate the user input here.
            if (!validator.Make(new string[] { id + "", mode + "" },
                new string[] { "required", "required"},
                new string[] { "userId", "mode" }))
            {
                return view.Error(validator.GetDetail());
            }

            userRepo.Destroy(id, mode);

            return view.Success();
        }
开发者ID:soxfmr,项目名称:CourseSystem,代码行数:15,代码来源:UserManagerController.cs

示例3: Update

        public string Update(int id, string name, string desc)
        {
            Validator validator = new Validator();

            // Validate the user input here.
            if (!validator.Make(new string[] { id + "", name, desc },
                new string[] { "required", "required", "required" },
                new string[] { "id", "name", "desc" }))
            {
                return view.Error(validator.GetDetail());
            }

            bool bRet = majorRepo.Update(id, name, desc);

            return bRet ? view.Success() : view.Error();
        }
开发者ID:soxfmr,项目名称:CourseSystem,代码行数:16,代码来源:MajorController.cs

示例4: Destroy

        public string Destroy(int id)
        {
            Validator validator = new Validator();

            // Validate the user input here.
            if (!validator.Make(new string[] { id + "" },
                new string[] { "required" },
                new string[] { "id" }))
            {
                return view.Error(validator.GetDetail());
            }

            bool bRet = majorRepo.Destroy(id);

            return bRet ? view.Success() : view.Error();
        }
开发者ID:soxfmr,项目名称:CourseSystem,代码行数:16,代码来源:MajorController.cs

示例5: Profile

        public string Profile(int id, int mode)
        {
            UserView view = new UserView();
            Validator validator = new Validator();
            // Validate the user input here.
            if (!validator.Make(new string[] { id + "", mode + "" },
                new string[] { "required", "required" },
                new string[] { "userId", "mode" }))
            {
                return view.Error(validator.GetDetail());
            }

            return userRepo.Exists(id, mode) ?
                view.Show(userRepo.CurrentUser) :
                view.Error();
        }
开发者ID:soxfmr,项目名称:CourseSystem,代码行数:16,代码来源:UserManagerController.cs

示例6: Update

        public string Update(int id, string weekday, DateTime at, int limit,
            int teacherId, int roomId)
        {
            Validator validator = new Validator();

            // Validate the user input here.
            if (!validator.Make(new string[] { id + "", weekday, at.ToString(), limit + "" },
                new string[] { "required", "required", "required", "required" },
                new string[] { "id", "weekday", "at", "limit" }))
            {
                return view.Error(validator.GetDetail());
            }
            // Enable the course by default
            bool bRet = dispatchMgrRepo.Update(id, weekday, at, limit, teacherId, roomId, true);

            return bRet ? view.Success() : view.Error();
        }
开发者ID:soxfmr,项目名称:CourseSystem,代码行数:17,代码来源:DispatchManageController.cs

示例7: AddStudentAbsence

        /// <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();
        }
开发者ID:soxfmr,项目名称:CourseSystem,代码行数:24,代码来源:AttendanceController.cs

示例8: OnRegister

        public string OnRegister(string email, string user, string pass)
        {
            RegisterView view = new RegisterView();
            Validator validator = new Validator();

            // Validate the user input here.
            if (!validator.Make(new string[] { email, user, pass },
                new string[] { "email", "minLength:1", "minLength:8" },
                new string[] { "email", "username", "password" }))
            {
                return view.Error(validator.GetDetail());
            }

            UserRepository userRepo = new UserRepository();
            int result = userRepo.Register(email, user, pass, 0);

            return view.Show(result);
        }
开发者ID:soxfmr,项目名称:CourseSystem,代码行数:18,代码来源:AuthController.cs

示例9: Store

        public string Store(string weekday, DateTime at,
            int limit,
            int teacherId, int courseId, int roomId)
        {
            Validator validator = new Validator();

            // Validate the user input here.
            if (!validator.Make(new string[] { weekday, at.ToString(), limit + "",
                            teacherId + "", courseId + "", roomId + ""},
                new string[] { "required", "required", "required", "required", "required", "required" },
                new string[] { "weekday", "at", "limit", "teacherId", "courseId", "roomId" }))
            {
                return view.Error(validator.GetDetail());
            }

            bool bRet = dispatchMgrRepo.Create(weekday, at, limit, teacherId, courseId, roomId);

            return bRet ? view.Success() : view.Error();
        }
开发者ID:soxfmr,项目名称:CourseSystem,代码行数:19,代码来源:DispatchManageController.cs

示例10: Store

        /// <summary>
        /// Add a new absence record
        /// </summary>
        /// <returns></returns>
        public string Store(string reason, int courseId)
        {
            Validator validator = new Validator();
            if (! validator.Make(new string[] { reason, courseId + "" },
                new string[] { "required", "required" },
                new string[] { "reason", "courseId" }))
            {
                return absenceView.Error(validator.GetDetail());
            }

            bool ret = absenceReasonRepo.Create(reason, courseId, Auth.User().Id);

            return ret ? absenceView.Success() : absenceView.Error();
        }
开发者ID:soxfmr,项目名称:CourseSystem,代码行数:18,代码来源:AbsenceController.cs

示例11: Store

        public string Store(string email, string user, string pass, int mode)
        {
            RegisterView view = new RegisterView();
            Validator validator = new Validator();

            // Validate the user input here.
            if (!validator.Make(new string[] { email, user, pass, mode + "" },
                new string[] { "email", "required", "required", "required" },
                new string[] { "email", "username", "password", "mode" }))
            {
                return view.Error(validator.GetDetail());
            }

            int result = userRepo.Register(email, user, pass, mode);

            return view.Show(result);
        }
开发者ID:soxfmr,项目名称:CourseSystem,代码行数:17,代码来源:UserManagerController.cs

示例12: Update

        public string Update(int id, int mode, 
            string name, string avatar, string cellphone)
        {
            Validator validator = new Validator();
            // Validate the user input here.
            if (!validator.Make(new string[] { id + "", mode + "", name},
                new string[] { "required", "required", "required" },
                new string[] { "userId", "mode", "username" }))
            {
                return view.Error(validator.GetDetail());
            }

            bool bRet = false;
            if (userRepo.Exists(id, mode))
            {
                userRepo.Update(userRepo.CurrentUser, name, avatar, cellphone, null);
                bRet = true;
            }

            return bRet ? view.Success() : view.Error();
        }
开发者ID:soxfmr,项目名称:CourseSystem,代码行数:21,代码来源:UserManagerController.cs

示例13: Store

        public string Store(int dispatchId, int absence)
        {
            Validator validator = new Validator();
            // Validate the user input here.
            if (! validator.Make(new string[] { dispatchId + "", absence + "" },
                new string[] { "required", "required|min:0" },
                new string[] { "dispatchId", "absence" }))
            {
                return resultSetView.Error(validator.GetDetail());
            }

            bool ret = attendanceRepo.Create(dispatchId, absence, Auth.User().Id);

            return ret ? resultSetView.Success() : resultSetView.Error();
        }
开发者ID:soxfmr,项目名称:CourseSystem,代码行数:15,代码来源:AttendanceController.cs

示例14: Update

        public string Update(string name, string avatar, string cellphone, 
            string newPwd, string pwdConfirm, string originPwd)
        {
            Validator validator = new Validator();
            // Validate the user input here.
            if (!validator.Make(new string[] { name, originPwd, newPwd, pwdConfirm },
                new string[] { "required", "required", "match:newPassword_confirmation", "" },
                new string[] { "username", "password", "newPassword", "newPassword_confirmation" }))
            {
                return userView.Error(validator.GetDetail());
            }

            UserRepository userRepo = new UserRepository();

            UserEntity user = Auth.User();
            if (! userRepo.Attempt(user.Email, originPwd, user.Mode))
            {
                return userView.Error();
            }

            userRepo.Update(user, name, avatar, cellphone, newPwd);

            return userView.Success();
        }
开发者ID:soxfmr,项目名称:CourseSystem,代码行数:24,代码来源:UserController.cs


注:本文中的Validator.Make方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。