本文整理汇总了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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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);
}
示例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();
}
示例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();
}
示例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);
}
示例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();
}
示例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();
}
示例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();
}