本文整理汇总了C#中Model.User类的典型用法代码示例。如果您正苦于以下问题:C# User类的具体用法?C# User怎么用?C# User使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
User类属于Model命名空间,在下文中一共展示了User类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddUserAndRetId
public int AddUserAndRetId(User user)
{
StringBuilder strSql = new StringBuilder();
strSql.Append("insert into [users]");
strSql.Append("(username,passwd) output inserted.uid values");
strSql.Append("(@UserName,@PassWord)");
SqlParameter[] parameters = {
new SqlParameter("@UserName",SqlDbType.VarChar,16),
new SqlParameter("@PassWord",SqlDbType.VarChar,64)
};
parameters[0].Value = user.UserName;
parameters[1].Value = user.Password;
SqlDataReader reader = SqlDbHelper.ExecuteReader(strSql.ToString(), CommandType.Text, parameters);
try
{
if (reader.Read())
{
return Int16.Parse(reader[0].ToString());
}
}
catch
{
return -1;
}
finally
{
reader.Close();
}
return -1;
}
示例2: LogIn
public void LogIn(String username, String password, bool rememberme, string ReturnUrl)
{
// We should authenticate against a database table or something similar
// but here, everything is ok as long as the
// password and username are non-empty
if (IsValid(username, password))
{
CancelView();
// Ideally we would look up an user from the database
// The domain model that represents the user
// could implement IPrincipal or we could use an adapter
User user = new User(username, new string[0]);
Session["user"] = user;
Redirect(ReturnUrl);
}
else
{
// If we got here then something is wrong
// with the supplied username/password
Flash["error"] = "Invalid user name or password. Try again.";
RedirectToAction("Index", "ReturnUrl=" + ReturnUrl);
}
}
示例3: SeedDatabase
protected static void SeedDatabase(FluentModel context)
{
User usr1 = new User()
{
UserId = 1,
Name = "Gary Adkins",
Note = "note note note",
Email = "[email protected]",
Income = 10000.324m
};
User usr2 = new User()
{
UserId = 2,
Name = "Tim Gordon",
Note = "note note note",
Email = "[email protected]",
Income = 10000.324m
};
User usr3 = new User()
{
UserId = 3,
Name = "Jack Jameson",
Note = "note note note",
Email = "[email protected]",
Income = 10000.324m
};
User usr4 = new User()
{
UserId = 4,
Name = "Bill Tompson",
Note = "note note note",
Email = "[email protected]",
Income = 10000.324m
};
Group administratorsGroup = new Group()
{
GroupId = 1,
Name = "Administrators",
Description = "admin group description",
};
administratorsGroup.UsersInGroup.Add(usr1);
administratorsGroup.UsersInGroup.Add(usr2);
Group coreUsersGroup = new Group()
{
GroupId = 2,
Name = "Core users",
Description = "core users description"
};
coreUsersGroup.UsersInGroup.Add(usr3);
coreUsersGroup.UsersInGroup.Add(usr4);
context.Add(administratorsGroup);
context.Add(coreUsersGroup);
context.SaveChanges();
}
示例4: RegisterUser_CreatedUser
protected void RegisterUser_CreatedUser(object sender, EventArgs e)
{
#region ["Method FormsAutentication"]
//FormsAuthentication.SetAuthCookie(RegisterUser.UserName, false /* createPersistentCookie */);
//string continueUrl = RegisterUser.ContinueDestinationPageUrl;
//if (String.IsNullOrEmpty(continueUrl))
//{
// continueUrl = "~/";
//}
//Response.Redirect(continueUrl);
#endregion
string continueUrl = "";
Model.User _userM = new Model.User();
FAMIS_BLL.User _userB = new FAMIS_BLL.User();
_userM.Login = RegisterUser.UserName;
_userM.Password = RegisterUser.Password;
string sRet = _userB.Add(_userM);
if (sRet == "")
{
continueUrl = "~/";
}
Response.Redirect(continueUrl);
}
示例5: btn_Add_Click
protected void btn_Add_Click(object sender, EventArgs e)
{
if (txt_Name.Text.Trim().ToLower() == "admin")
{
UtilityService.Alert(this.Page,"admin是非法用户名,请换一个用户名称!");
return;
}
Model.User u = new Model.User();
u.UserID = txt_UM.Text.Trim();
u.UserName = txt_Name.Text.Trim();
//u.Password = txt_Pwd.Text.Trim();
u.Status = 1;
u.OrganID = int.Parse(ddl_Organ.SelectedValue.ToString());//(int)Session["OrganID"];
u.OpenDate = DateTime.Parse(txt_OpenDate.Text);
u.InputBy = Session["UserID"].ToString();
DataSet oldU = new UserBLL().GetList(" UserID = '" + u.UserID + "'");
if (oldU != null && oldU.Tables[0].Rows.Count > 0)
{
UtilityService.Alert(this, "该用户名已存在!");
return;
}
int re = new UserBLL().Add(u);
if (re > 0)
{
UtilityService.AlertAndRedirect(this, "添加成功!", "UserMgr.aspx");
}
else
{
UtilityService.Alert(this, "添加失败!");
}
}
示例6: frmPaymentTermial
/// <summary>
/// 无参构造函数
/// 内容初始化为测试模式
/// 需要参数的内容为null
/// </summary>
public frmPaymentTermial()
{
labelTitle.Text = frmSetting.paymentTitle;
user = new User("pirat", -1, "-1") ;
supermarket = null;
InitializeComponent();
}
示例7: frmMain
/// <summary>
/// 无参构造基本窗体
/// </summary>
public frmMain()
{
InitializeComponent();
user = new User("piratf", -1, "-1");
wn = null;
wt = null;
}
示例8: Clone
public User Clone(User _user)
{
this.userID = _user.userID;
this.level = _user.level;
this.supermarket = _user.supermarket;
return this;
}
示例9: SaveUser
public ActionResult SaveUser(User user)
{
user.CurrentCompany = CompanyManager.Get(user.CurrentCompany.CompanyID);
UserManager.Save(user);
return RedirectToAction("GetCompany", "Home", new { id = user.CurrentCompany.CompanyID });
}
示例10: Can_Add_User
public void Can_Add_User()
{
// Arrange .. create the user
string displayName = "Galilyou";
string email = "[email protected]";
User user = new User();
user.DisplayName = displayName;
user.Email = email;
IUserRepository repository = _serviceLocator.Locate<IUserRepository>();
// act ...
repository.Add(user);
// now try to get the saved in user
var tryToFindUser = repository.Filter(
c => c.DisplayName == displayName,
c => c.Email == email
);
// assert
Assert.Greater(tryToFindUser.Count(), 0);
}
示例11: Connection_Connect_Behaviour_DisconnectUnconnectedUser
public void Connection_Connect_Behaviour_DisconnectUnconnectedUser()
{
User dummy = new User() { Name = "Crash Test Dummy", Password = "Not again!" };
PieServiceClient pieService = new PieServiceClient();
pieService.Disconnect(dummy);
//It's okay to disconnect a user even if he isn't connected
}
示例12: CreateNewUser
public User CreateNewUser(string username, string password, string email)
{
var author = new User {UserName = username, Password = password, Email = email};
_userRepository.SaveUser(author);
var userRegistered = new UserRegisteredEventArgs(this, author);
UserRegistered.Raise(userRegistered);
return author;
}
示例13: Can_reset_password
public void Can_reset_password()
{
var author = new User {Email = "[email protected]", Password = "1234"};
userRepository.Expect(x => x.GetAuthorByEmail("[email protected]"))
.Return(author);
membershipService.ResetPassword("[email protected]");
userRepository.AssertWasCalled(x => x.SaveUser(author));
Assert.AreNotEqual(author.Password, "1234");
}
示例14: Connection_Connect_Behaviour_ConnectTwice
public void Connection_Connect_Behaviour_ConnectTwice()
{
User dummy = new User() { Name = "Crash Test Dummy", Password = "Not again!" };
PieServiceClient pieService = new PieServiceClient();
pieService.Connect(dummy);
pieService.Connect(dummy);
//It's okay for a user to connect twice
}
示例15: AddWeblog
public static void AddWeblog(User model)
{
using (var db = DbBase.CreateDBContext())
{
var list = db.GetCollection<User>("users");
list.Insert(model);
}
}