public List<Athlete> CreateRandomAthletes(int numberOfAthletes) { var r = new RandomProvider(); var dateMin = new DateTime(1920, 1, 1); var dateMax = new DateTime(2020, 1, 1); var athletes = new List<Athlete>(); using (var db = new DbDataContext()) { var athleteCountBefore = db.Athletes.Count(); for (var i = 0; i < numberOfAthletes; i++) { var firstName = _randomFirstNamePrefix + i; var lastName = _randomLastNamePrefix + i; //var guid = Guid.NewGuid().ToString(); var user = new User { Password = "******", UserName = firstName, Roles = "" }; var athlete = new Athlete { FirstName = firstName, LastName = lastName, DateOfBirth = r.Next(dateMin, dateMax), User = user }; athletes.Add(athlete); db.Users.InsertOnSubmit(user); } db.SubmitChanges(); var athleteCountAfter = db.Athletes.Count(); Assert.AreEqual(numberOfAthletes, athletes.Count); Assert.AreEqual(athleteCountAfter, athleteCountBefore + numberOfAthletes); } return athletes; }
private void InsertDefaultAthlete(int weight) { var user = new User { ID = 1, Password = "******", UserName = "******" }; MemoryDataContext.InsertOnSubmit(user); MemoryDataContext.Commit(); new UserDataAccess().Save(user); _athlete = new Athlete { ID = 0, User = user, Weight = weight}; new AthleteDataAccess().SaveAthlete(_athlete); }
public User CreateUserWithDefaultAthlete(string emailAsUserName, string password) { var user = new User {Password = password, UserName = emailAsUserName}; DataContext.InsertOnSubmit(user); DataContext.Commit(); user.CustomerID = user.ID.ToString(); DataContext.Commit(); var athlete = new Athlete {User = user}; DataContext.InsertOnSubmit(athlete); DataContext.Commit(); return user; }
public Athlete Build() { var user = new User {UserName = "******", ID = 10}; var dateOfBirth = DateTime.MinValue; var athlete = new Athlete { DateOfBirth = dateOfBirth, FirstName = "Gryffe", ID = 1, LastName = null, User = user, }; return athlete; }
public void LogoutUser(User user) { user.SetAuthenticated(false); }
public Athlete GetAthlete(User user) { var existingAthlete = DataContext.Queryable<Athlete>().Single(athlete => athlete.User.Equals(user)); return existingAthlete; }
partial void DeleteUser(User instance);
partial void UpdateUser(User instance);
partial void InsertUser(User instance);
public User Save(User user) { DataContext.UpdateAndAttach(user); DataContext.Commit(); return user; }