Esempio n. 1
0
        public static void SeedUsers(IUserDataContext userDataContext, IPhotosDataContext photosDataContext)
        {
            if (!userDataContext.GetAllUsersByLastActive().Result.Any())
            {
                System.Console.WriteLine("Seeding users...");
                var userData = System.IO.File.ReadAllText("Data/UserSeedData.json");
                var users    = JsonConvert.DeserializeObject <List <User> >(userData);
                foreach (var user in users)
                {
                    byte[] passwordHash, passwordSalt;
                    CreatePasswordHash("password", out passwordHash, out passwordSalt);

                    user.PasswordHash = passwordHash;
                    user.PasswordSalt = passwordSalt;
                    user.Username     = user.Username.ToLower();
                    userDataContext.Add(user);

                    foreach (var photo in user.PhotosFromSeed)
                    {
                        photo.UserId = userDataContext.GetByUsername(user.Username).Result.Id;
                        photosDataContext.Add(photo);
                    }
                }
                System.Console.WriteLine("User Seed complete.");
            }
        }
 public User(
     IPhotosDataContext photosDataContext     = null,
     ILikesDataContext likesDataContext       = null,
     IMessagesDataContext messagesDataContext = null)
 {
     _photosDataContext   = photosDataContext;
     _likesDataContext    = likesDataContext;
     _messagesDataContext = messagesDataContext;
 }
Esempio n. 3
0
 public UserDataContext(
     IDbAccess dbAccess,
     IPhotosDataContext photosDataContext,
     IMessagesDataContext messagesDataContext,
     ILikesDataContext likesDataContext)
 {
     _dbAccess            = dbAccess;
     _photosDataContext   = photosDataContext;
     _messagesDataContext = messagesDataContext;
     _likesDataContext    = likesDataContext;
 }
 public DatingRepository(
     IUserDataContext userDataContext,
     ILikesDataContext likesDataContext,
     IPhotosDataContext photosDataContext,
     IMessagesDataContext messagesDataContext)
 {
     _userDataContext     = userDataContext;
     _likesDataContext    = likesDataContext;
     _photosDataContext   = photosDataContext;
     _messagesDataContext = messagesDataContext;
 }