private User[] GenerateValidItems(int itemsCount = 15) { User[] itemsSet = new User[itemsCount]; for (int i = 0; i < itemsCount; i++) { var currentItem = new User() { UserName = string.Format("user{0}@abv.bg", i), Rank = i * 100, }; itemsSet[i] = currentItem; } return itemsSet; }
private async Task SignInAsync(User user, bool isPersistent) { AuthenticationManager.SignOut(DefaultAuthenticationTypes.ExternalCookie, DefaultAuthenticationTypes.TwoFactorCookie); AuthenticationManager.SignIn(new AuthenticationProperties { IsPersistent = isPersistent }, await user.GenerateUserIdentityAsync(UserManager)); }
/// <summary> /// Deprecated Method for adding a new object to the Users EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToUsers(User user) { base.AddObject("Users", user); }
/// <summary> /// Checks if the user already exists in the database and does an update /// </summary> /// <param name="uid">FB UserID </param> /// <param name="email">FB Email</param> /// <param name="username">FB Username</param> /// <param name="firstname">FB Firstname</param> /// <param name="lastname">FB Lastname</param> /// <param name="gender">FB Gender</param> /// <param name="birthday">FB Birthday</param> public void UpdateUser(string uid, string email, string username, string firstname, string lastname, string gender, string birthday) { var user = this.db.Users.Where(x => x.UserName == username).ToList(); if (user.Count == 0) { var u = new User(); u.UserID = Guid.NewGuid(); u.UserKey = uid; u.UserName = username; u.Email = email; u.FirstName = firstname; u.LastName = lastname; u.Gender = gender; u.Birthdate = Convert.ToDateTime(birthday); u.CreatedDate = DateTime.Now; u.LastModifiedDate = DateTime.Now; u.LastLoginDate = DateTime.Now; u.IsActivated = true; u.IsLockedOut = false; this.db.AddToUsers(u); this.db.SaveChanges(); } }
/// <summary> /// Create a new User object. /// </summary> /// <param name="userID">Initial value of the UserID property.</param> public static User CreateUser(global::System.Guid userID) { User user = new User(); user.UserID = userID; return user; }