本文整理汇总了C#中UserRepository.GetUser方法的典型用法代码示例。如果您正苦于以下问题:C# UserRepository.GetUser方法的具体用法?C# UserRepository.GetUser怎么用?C# UserRepository.GetUser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserRepository
的用法示例。
在下文中一共展示了UserRepository.GetUser方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Delete_ShouldDeleteUser
public void Delete_ShouldDeleteUser()
{
//arrange
var userRepository = new UserRepository(Properties.Resources.ConnectionString);
User user = TestDataHelper.GenerateUser();
//act
userRepository.CreateUser(user);
User userBeforeDelete = userRepository.GetUser(user.Id);
if (userBeforeDelete == null)
{
Console.WriteLine("User not exist!");
}
else
{
Console.WriteLine("User exist.");
}
userRepository.DeleteUser(user.Id);
//assert
User userAfterDelete = userRepository.GetUser(user.Id);
if (userAfterDelete == null)
{
Console.WriteLine("User deleted.");
}
else
{
Console.WriteLine("User not deleted!");
}
Assert.IsTrue(!(userBeforeDelete == null) & (userAfterDelete == null));
}
示例2: AddLastUser
public void AddLastUser()
{
UserRepository repository = new UserRepository();
User user = new User(ulong.MaxValue, "last");
repository.SetUser(user);
User result = repository.GetUser(user.Id);
Assert.IsNotNull(result);
Assert.AreEqual(user, result);
}
示例3: LoginUserMessage
private void LoginUserMessage(object obj)
{
var password = ((System.Windows.Controls.PasswordBox)obj).Password;
_userRepo = new UserRepository();
User user = _userRepo.GetUser(Username, password);
if(user != null)
{
// MainViewModel should lisent to this
Messenger.Default.Send<User>(user, "UserLogin");
}
Messenger.Default.Send<bool>(true, "CloseLoginView");
}
示例4: Get_ByEmail_ShouldReturnUser
public void Get_ByEmail_ShouldReturnUser()
{
//arrange
var userRepository = new UserRepository(Properties.Resources.ConnectionString);
User user = TestDataHelper.GenerateUser();
//act
userRepository.CreateUser(user);
var resultUser = userRepository.GetUser(user.Email);
//asserts
TestDataHelper.PrintUserInfo(resultUser);
Assert.IsTrue(TestDataHelper.CompareUsers(user, resultUser));
}
示例5: btn_loginUser_Click
protected void btn_loginUser_Click(object sender, EventArgs e)
{
UserRepository userR = new UserRepository();
string password = txt_PasswordLogin.Text;
string user = txt_UserLogin.Text;
var obj = userR.GetUser(user, password);
if (obj.IsAdmin == true)
//navigate and set admin
Response.Redirect("Admin_Home.aspx");
else
//navigate and set user
Response.Redirect("User_Home.aspx");
}
示例6: Create_ShouldCreateUser
public void Create_ShouldCreateUser()
{
//arrange
var userRepository = new UserRepository(Properties.Resources.ConnectionString);
User user = TestDataHelper.GenerateUser();
user.FirstName = "TestUser";
//act
userRepository.CreateUser(user);
//asserts
var resultUser = userRepository.GetUser(user.Id);
TestDataHelper.PrintUserInfo(resultUser);
Assert.IsTrue(TestDataHelper.CompareUsers(user, resultUser));
}
示例7: MakeSureAdminIsCreated
private void MakeSureAdminIsCreated()
{
var userRepo = new UserRepository();
var adminUser = userRepo.GetUser("admin");
if(adminUser != null)
return;
adminUser = new User()
{
Username = "admin",
EncryptedPassword = EncryptedPassword.Create("qwerty")
};
userRepo.SaveUser(adminUser);
}
示例8: AddOneThousandUsers
public void AddOneThousandUsers()
{
UserRepository repository = new UserRepository();
for (ushort k = 1; k <= 1000; k++)
{
User user = new User(k, "user" + k);
repository.SetUser(user);
}
for (ushort k = 1; k <= 1000; k++)
{
User result = repository.GetUser(k);
Assert.IsNotNull(result);
Assert.AreEqual((ulong)k, result.Id);
Assert.AreEqual("user" + k, result.Name);
}
}
示例9: Trivia
//
// GET: /Trivia/
public ActionResult Trivia()
{
Guid userId;
if (Session["UserID"] == null || !Guid.TryParse(Session["UserID"].ToString(), out userId))
{
return RedirectToAction("Index", "Home");
}
var userRepository = new UserRepository();
var gameRepository = new GameRepository();
var currentUser = userRepository.GetUser(userId);
var currentGame = gameRepository.CreateGame(userId);
var viewModel = new TriviaViewModel
{
CurrentUser = currentUser,
CurrentGame = currentGame
};
return View(viewModel);
}
示例10: btnSubmit_Click
protected void btnSubmit_Click(object sender, EventArgs e)
{
var rep = new UserRepository(new CSBCDbContext());
User user = rep.GetUser(txtUserName.Text, txtPassword.Text);
if ((user == null) || (user.UserID == 0))
{
lblError.Text = "Invalid user / password";
lblError.Visible = true;
}
else
{
Session["UserID"] = user.UserID;
Session["UserName"] = user.Name;
Session["UserType"] = user.UserType;
Session["CompanyID"] = rep.GetById(user.UserID).CompanyID;
Session["TestMode"] = checkTestMode.Checked;
var seasonrep = new SeasonRepository(new CSBCDbContext());
var season = seasonrep.GetCurrentSeason((int)Session["CompanyID"]);
Session["SeasonID"] = season.SeasonID;
Response.Redirect("welcome1.aspx");
}
}
示例11: GetUser
public override MembershipUser GetUser(string username, bool userIsOnline)
{
UserRepository _user = new UserRepository();
return _user.GetUser(username);
}
示例12: GetUserAccess
private void GetUserAccess()
{
var msg = "Invalid use name / password combination";
var giveAccess = false;
using (var db = new CSBCDbContext())
{
var rep = new UserRepository(db);
User user = rep.GetUser(txtUserName.Text, txtPassword.Text);
if (user != null & user.HouseID != 0)
{
if (user.PassWord.ToUpper() == txtPassword.Text.ToUpper())
{
var repoRole = new RoleRepository(db);
var accessTypes = repoRole.GetRoles(user.UserID);
Session["User"] = user;
if (accessTypes.Any(r => r.ScreenName.ToUpper() == "SCORES"))
{
giveAccess = true;
Session["Editing"] = "All";
}
else
{
//check to see if they are AD
var divisionId = Convert.ToInt32(ddlDivisions.SelectedValue);
giveAccess = CheckAD(divisionId, user);
if (!giveAccess)
{
msg = "Use does not have right to edit scores";
}
}
if (giveAccess)
{
//btnEdit1.Visible = true;
grdSchedule.Columns[9].Visible = true;
}
Session["UserID"] = user.UserID;
Session["UserName"] = user.Name;
Session["UserType"] = user.UserType;
lblName.Text = user.Name;
lblName.Visible = true;
btnLogout.Visible = true;
loginForm.Visible = false;
return;
}
else
{
msg = "Incorrect password";
}
}
}
labelLoginError.Text = msg;
labelLoginError.Visible = true;
}
示例13: VerifyUserNameHasConfirmedAccount
private static Guid VerifyUserNameHasConfirmedAccount(string userName, bool throwException)
{
var repo = new UserRepository();
var user = repo.GetUser(userName);
if (user == null)
{
if (throwException)
{
throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture,
"User {0} does not exist!",
new object[] {userName}));
}
}
return user == null || !user.IsConfirmed ? Guid.Empty : user.Id;
}
示例14: InitUserProfile
static string InitUserProfile(string username, string firstname, string lastname, string email, bool createToken)
{
var repo = new UserRepository();
var token = string.Empty;
var user = repo.GetUser(username);
if (user != null)
{
user.UserProfile.FirstName = firstname;
user.UserProfile.LastName = lastname;
//create token for email confirmation
if (createToken)
{
token = GenerateToken();
user.ConfirmationToken = token;
}
//otherwise - confirmed
else
{
user.IsConfirmed = true;
}
repo.Update(user);
}
return token;
}
示例15: HasPerm
public bool HasPerm(string username, string customperm)
{
UserRepository _repository = new UserRepository();
MembershipUser user = _repository.GetUser(username);
if (user != null)
{
return _repository.HasPerm(int.Parse((user.ProviderUserKey).ToString()), customperm);
}
else
{
return false;
}
}