本文整理汇总了C#中Role.Equals方法的典型用法代码示例。如果您正苦于以下问题:C# Role.Equals方法的具体用法?C# Role.Equals怎么用?C# Role.Equals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Role
的用法示例。
在下文中一共展示了Role.Equals方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ValidateCreateModel
private string ValidateCreateModel(CreateUserBindingModel createModel, Role role)
{
string msg = String.Empty;
if (role.Equals(Role.Affiliate))
{
int category;
if (!int.TryParse(createModel.UserCategory, out category))
{
msg = "That is not a valid user category";
ModelState.AddModelError("createUserModel.UserCategory", msg);
}
}
if (role.Equals(Role.Vendor))
{
if (String.IsNullOrEmpty(createModel.ProgramDescription))
{
msg = "Please enter a Program Description";
ModelState.AddModelError("createUserModel.ProgramDescription", msg);
}
if (String.IsNullOrEmpty(createModel.ProgramName))
{
msg = "Please enter a Program Name";
ModelState.AddModelError("createUserModel.ProgramName", msg);
}
Program program = MarketManager.GetAllPrograms().Where(p => p.Name.ToLower() == createModel.ProgramName.ToLower()).FirstOrDefault();
if (null != program)
{
msg = "That program name is already taken, please enter something different";
ModelState.AddModelError("createUserModel.ProgramName", msg);
}
int category;
if (!int.TryParse(createModel.ProgramCategory, out category))
{
msg = "That is not a valid program category";
ModelState.AddModelError("createUserModel.ProgramCategory", msg);
}
if (String.IsNullOrEmpty(createModel.ProgramUrl))
{
msg = "Please enter a Program Url";
ModelState.AddModelError("createUserModel.ProgramUrl", msg);
}
}
return msg;
}
示例2: RegisterUser
public static UserProfile RegisterUser(String login, String password,Role role)
{
connection.Open();
command = new SQLiteCommand("INSERT INTO 'User_Profile' (user_id,login,password,isAdmin) VALUES (@param1,@param2,@param3,@param4)", connection);
int id = IDGenerator.CreateId();
string isAdmin;
if (role.Equals(Role.STUDENT))
{
isAdmin = "0";
}
else
{
isAdmin = "1";
}
command.Parameters.Add(new SQLiteParameter("@param1", id));
command.Parameters.Add(new SQLiteParameter("@param2", login));
command.Parameters.Add(new SQLiteParameter("@param3", password));
command.Parameters.Add(new SQLiteParameter("@param4", isAdmin));
command.ExecuteNonQuery();
connection.Close();
return new UserProfile(login, password, Role.STUDENT, id);
}