本文整理汇总了C#中User类的典型用法代码示例。如果您正苦于以下问题:C# User类的具体用法?C# User怎么用?C# User使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
User类属于命名空间,在下文中一共展示了User类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: VMQuickContact
public VMQuickContact(User user)
{
FirstName = user.FirstName;
LastName = user.LastName;
Email = user.Email;
UserId = user.Id;
}
示例2: PutUser
public IHttpActionResult PutUser(int id, User user)
{
if (!ModelState.IsValid)
{
return BadRequest(ModelState);
}
if (id != user.carsite_id)
{
return BadRequest();
}
db.Entry(user).State = EntityState.Modified;
try
{
db.SaveChanges();
}
catch (DbUpdateConcurrencyException)
{
if (!UserExists(id))
{
return NotFound();
}
else
{
throw;
}
}
return StatusCode(HttpStatusCode.NoContent);
}
示例3: CalculateBadges
public void CalculateBadges(User user, List<BadgeType> badgeTypes)
{
foreach (var badgeType in badgeTypes)
{
this.badgeStrategyFactory.GetBadgeStrategy(badgeType).CalculateBadges(user, badgeType);
}
}
示例4: Update
public User Update(User user)
{
this.users.Update(user);
this.users.SaveChanges();
return user;
}
示例5: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
if (!Permission.Check("user.read", true)) return;
if (!Page.IsPostBack)
{
using (MooDB db = new MooDB())
{
int userAID = int.Parse(Request["userA"]);
int userBID = int.Parse(Request["userB"]);
userA = (from u in db.Users
where u.ID == userAID
select u).SingleOrDefault<User>();
userB = (from u in db.Users
where u.ID == userBID
select u).SingleOrDefault<User>();
if (userA == null || userB == null)
{
PageUtil.Redirect(Resources.Moo.FoundNothing, "~/");
return;
}
BindDatas(db);
Page.DataBind();
}
}
}
示例6: GetUserDomainModel
public User GetUserDomainModel(UserViewModel userViewModel)
{
var user = new User();
user.Name = userViewModel.Name;
user.Password = userViewModel.Password;
return user;
}
示例7: PassOne
public PassOne(User user)
{
InitializeComponent();
//UserManager.CreateUser("Peter", "Varner-Howland", "pvarnerhowland", "testPass321");
//var user = UserManager.Authenticate("pvarnerhowland", "testPass321");
_myApp = new PassOneApp(this, user);
}
示例8: When
public void When(UserAttachedToRegistration e)
{
if (null == FirstUser)
{
FirstUser = new User(e.UserId, e.UserDisplay, e.Token);
}
}
示例9: CheckRole
public int CheckRole(User user)
{
var pass = encrypt(user.Password);
var m = db.Users.Where(x => x.UserName == user.UserName && x.Password == pass && x.IdRole == 1).SingleOrDefault();
var n = db.Users.Where(x => x.UserName.Equals(user.UserName) && x.Password != user.Password && x.IdRole == 1).SingleOrDefault();
if (m!=null && m.LoginFail <= 3)
{
var p = decrypt(m.Password);
FormsAuthentication.SetAuthCookie(m.UserName.ToString(), false);
return 1;
}
else if (n != null && n.LoginFail < 3)
{
n.LoginFail++;
db.SaveChanges();
return 0;
}
else if (m != null && m.LoginFail >= 3)
{
return 2;
}
else if (n != null && n.LoginFail >= 3)
{
return 3;
}
return 0;
}
示例10: HistoryWindow
public HistoryWindow()
{
InitializeComponent();
historial = new Historiales();
medic = new Medic();
user = new User();
history = new History();
medics = medic.GetAll();
users = user.GetAll();
histories = history.GetAll();
foreach (Usuarios user in users)
{
comboUsers.Items.Add(user.nombre + " " + user.apellidos);
}
foreach (Medicos medic in medics)
{
comboMedics.Items.Add(medic.nombre + " " + medic.apellidos);
}
historialGrid.ItemsSource = histories.ToArray();
}
示例11: Purchase
public Purchase(int puchaseId, Cart cart, User user, DateTime date)
{
this.PurchaseID = puchaseId;
this.articles = cart;
this.User = user;
this.Date = date;
}
示例12: matches_credentials_negative
public void matches_credentials_negative()
{
var user1 = new User
{
UserName = "jeremy",
Password = theHash.CreateHash("something")
};
var user2 = new User
{
UserName = "josh",
Password = theHash.CreateHash("else")
};
theRepository.Update(user1);
theRepository.Update(user2);
theMembership.MatchesCredentials(new LoginRequest
{
UserName = "jeremy",
Password = "something"
}).ShouldBeTrue();
theMembership.MatchesCredentials(new LoginRequest
{
UserName = "josh",
Password = "else"
}).ShouldBeTrue();
}
示例13: AddUser
/// <summary>
/// Adds a user to the system, and sets the <see cref="User.IsActivated"/> to true.
/// </summary>
/// <param name="email">The email or username.</param>
/// <param name="password">The password.</param>
/// <param name="isAdmin">if set to <c>true</c> the user is added as an admin.</param>
/// <param name="isEditor">if set to <c>true</c> the user is added as an editor.</param>
/// <returns>
/// true if the user was added; false if the user already exists.
/// </returns>
/// <exception cref="SecurityException">An NHibernate (database) error occurred while adding the new user.</exception>
public override bool AddUser(string email, string username, string password, bool isAdmin, bool isEditor)
{
try
{
User user = Users.FirstOrDefault(u => u.Email == email || u.Username == username);
if (user == null)
{
user = new User();
user.Email = email;
user.Username = username;
user.SetPassword(password);
user.IsAdmin = isAdmin;
user.IsEditor = isEditor;
user.IsActivated = true;
NHibernateRepository.Current.SaveOrUpdate<User>(user);
return true;
}
else
{
return false;
}
}
catch (HibernateException ex)
{
throw new SecurityException(ex, "An error occurred while adding the new user {0}", email);
}
}
示例14: AddUser
public void AddUser(FormCollection collection, User user)
{
UserBLL ub = new UserBLL();
String message=ub.AddNewUser(collection,user);
Index();
}
示例15: ToViewModel
public static UserModel ToViewModel(this User a, User viewer, bool isOfficerAsking)
{
int privacyLevel = (viewer == null) ? 0 : viewer.PrivacyLevel;
return new UserModel
{
Alias = a.Alias ?? a.Name,
UserId = a.ID,
Bio = a.Bio,
BirthDate = (((a.PrivacyLevel < 2) || (privacyLevel < 2)) || !a.Birthdate.HasValue) ? null : (((a.PrivacyLevel < 3) || (privacyLevel < 3)) ? a.Birthdate.Value.ToString("MMMM dd") : a.Birthdate.Value.ToString("MMMM dd, yyyy")),
Furcode = a.FurCode,
InterestTags = a.Interests,
Messenger1Id = (privacyLevel == 0) ? null : a.Messenger1ID,
Messenger1Type = (privacyLevel == 0) ? null : a.Messenger1Type,
Messenger2Id = (privacyLevel == 0) ? null : a.Messenger2ID,
Messenger2Type = (privacyLevel == 0) ? null : a.Messenger2Type,
Messenger3Id = (privacyLevel == 0) ? null : a.Messenger3ID,
Messenger3Type = (privacyLevel == 0) ? null : a.Messenger3Type,
Messenger4Id = (privacyLevel == 0) ? null : a.Messenger4ID,
Messenger4Type = (privacyLevel == 0) ? null : a.Messenger4Type,
Orientation = (privacyLevel == 0) ? null : (((string.Compare(a.Sex, "Female") == 0) && (string.CompareOrdinal(a.Orientation, "Gay") == 0)) ? "Lesbian" : a.Orientation),
PrivacyLevel = a.PrivacyLevel,
RelationshipStatus = (privacyLevel == 0) ? null : a.RelationshipStatus,
Sex = a.Sex,
Species = a.Species,
SpeciesDetails = a.SpeciesDetails,
Username = a.Name
};
}