-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
276 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
using Friendster.Models; | ||
using Newtonsoft.Json; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Security.Cryptography; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Friendster.Data | ||
{ | ||
public class Seeder | ||
{ | ||
private DataContext _context; | ||
|
||
public Seeder(DataContext context) | ||
{ | ||
_context = context; | ||
} | ||
|
||
public void SeedUsers() | ||
{ | ||
if (!_context.Users.Any()) | ||
{ | ||
Console.WriteLine("Seeding users"); | ||
var contents = File.ReadAllText("Data/Seeds/UserSeeds.json"); | ||
var users = JsonConvert.DeserializeObject<List<User>>(contents); | ||
foreach (var user in users) | ||
{ | ||
CreatePasswordHash(out byte[] passwordHash, out byte[] passwordSalt); | ||
user.PasswordHash = passwordHash; | ||
user.PasswordSalt = passwordSalt; | ||
user.Username = user.Username.ToLower(); | ||
|
||
_context.Users.Add(user); | ||
} | ||
|
||
_context.SaveChanges(); | ||
} | ||
} | ||
|
||
private void CreatePasswordHash(out byte[] passwordHash, out byte[] passwordSalt) | ||
{ | ||
using (var hmac = new HMACSHA512()) | ||
{ | ||
passwordSalt = hmac.Key; | ||
passwordHash = hmac.ComputeHash(Encoding.UTF8.GetBytes("password")); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,212 @@ | ||
[ | ||
{ | ||
"Username": "Bridgette", | ||
"Gender": 1, | ||
"DateOfBirth": "1986-08-06", | ||
"Password": "password", | ||
"KnownAs": "Bridgette", | ||
"Created": "2017-08-08", | ||
"LastActive": "2017-08-08", | ||
"Introduction": "Laboris cillum enim velit ad incididunt in ullamco eiusmod sunt deserunt nulla fugiat consectetur voluptate. Occaecat non et in ipsum deserunt in pariatur eu reprehenderit incididunt incididunt laborum qui duis. Enim pariatur anim incididunt anim quis nisi adipisicing cillum sit. Commodo irure est nulla enim dolor dolor eiusmod cillum eu id. Excepteur ipsum mollit fugiat do cillum ea duis cupidatat aliquip aliqua culpa. Culpa velit incididunt ex adipisicing irure ipsum.\r\n", | ||
"LookingFor": 2, | ||
"Interests": "Consectetur cupidatat enim velit esse excepteur irure ullamco do nulla laboris est in laborum adipisicing.", | ||
"City": "Ebro", | ||
"Country": "Egypt", | ||
"Photos": [ | ||
{ | ||
"url": "https://randomuser.me/api/portraits/women/53.jpg", | ||
"isMain": true, | ||
"description": "Nostrud in exercitation pariatur ea ipsum duis adipisicing cupidatat aute exercitation adipisicing officia." | ||
} | ||
] | ||
}, | ||
{ | ||
"Username": "Karen", | ||
"Gender": 1, | ||
"DateOfBirth": "1979-06-04", | ||
"Password": "password", | ||
"KnownAs": "Karen", | ||
"Created": "2017-02-26", | ||
"LastActive": "2017-02-26", | ||
"Introduction": "Cillum do excepteur sint in Lorem magna laboris fugiat ad laborum. Ex deserunt quis nulla nostrud. Exercitation velit aute non est sit voluptate. Est nostrud laboris duis mollit ea fugiat laboris velit cillum. Cillum nostrud eu excepteur cupidatat veniam dolor laboris magna consectetur quis. Anim nisi anim tempor deserunt deserunt consequat ex proident non.\r\n", | ||
"LookingFor": 0, | ||
"Interests": "Esse magna pariatur sunt duis consequat sunt nisi.", | ||
"City": "Craig", | ||
"Country": "Ethiopia", | ||
"Photos": [ | ||
{ | ||
"url": "https://randomuser.me/api/portraits/women/53.jpg", | ||
"isMain": true, | ||
"description": "Elit velit excepteur commodo velit sunt proident ea id deserunt pariatur do nisi eu cillum." | ||
} | ||
] | ||
}, | ||
{ | ||
"Username": "Patricia", | ||
"Gender": 1, | ||
"DateOfBirth": "1989-05-07", | ||
"Password": "password", | ||
"KnownAs": "Patricia", | ||
"Created": "2017-04-18", | ||
"LastActive": "2017-04-18", | ||
"Introduction": "Nisi ullamco eu excepteur id reprehenderit labore incididunt. Do laborum irure incididunt ullamco ut deserunt elit dolor minim et anim consequat cupidatat. Quis exercitation irure reprehenderit fugiat aute do adipisicing dolor culpa sunt aliqua est et cupidatat. Eu elit aliqua quis in minim magna amet. Anim eu ea commodo mollit nostrud qui deserunt reprehenderit.\r\n", | ||
"LookingFor": 1, | ||
"Interests": "Id sunt ad velit ex qui tempor laboris exercitation duis tempor dolore cupidatat culpa officia.", | ||
"City": "Lacomb", | ||
"Country": "Armenia", | ||
"Photos": [ | ||
{ | ||
"url": "https://randomuser.me/api/portraits/women/20.jpg", | ||
"isMain": true, | ||
"description": "Anim veniam tempor sunt do enim laborum occaecat veniam ipsum." | ||
} | ||
] | ||
}, | ||
{ | ||
"Username": "Jill", | ||
"Gender": 1, | ||
"DateOfBirth": "1989-01-25", | ||
"Password": "password", | ||
"KnownAs": "Jill", | ||
"Created": "2017-04-14", | ||
"LastActive": "2017-04-14", | ||
"Introduction": "Ad cillum occaecat esse laboris minim incididunt reprehenderit esse Lorem irure. Consequat laboris officia occaecat exercitation aliqua dolor ullamco occaecat. Fugiat duis sit sint et adipisicing cillum nostrud sit irure anim nostrud elit.\r\n", | ||
"LookingFor": 1, | ||
"Interests": "Enim in deserunt quis incididunt.", | ||
"City": "Independence", | ||
"Country": "Finland", | ||
"Photos": [ | ||
{ | ||
"url": "https://randomuser.me/api/portraits/women/60.jpg", | ||
"isMain": true, | ||
"description": "Laborum eu fugiat exercitation quis aliquip voluptate adipisicing esse." | ||
} | ||
] | ||
}, | ||
{ | ||
"Username": "Rosemarie", | ||
"Gender": 1, | ||
"DateOfBirth": "1971-06-26", | ||
"Password": "password", | ||
"KnownAs": "Rosemarie", | ||
"Created": "2017-01-10", | ||
"LastActive": "2017-01-10", | ||
"Introduction": "Consequat commodo consectetur minim anim cillum mollit eiusmod tempor. Consequat magna in proident exercitation cupidatat adipisicing duis. Cillum incididunt enim ea tempor ipsum in commodo ex.\r\n", | ||
"LookingFor": 0, | ||
"Interests": "Sint duis qui ullamco eu veniam in dolor fugiat sit sint do.", | ||
"City": "Garberville", | ||
"Country": "Singapore", | ||
"Photos": [ | ||
{ | ||
"url": "https://randomuser.me/api/portraits/women/15.jpg", | ||
"isMain": true, | ||
"description": "Id aliquip excepteur aliquip laboris tempor non proident nisi sunt culpa anim est sit ipsum." | ||
} | ||
] | ||
}, | ||
{ | ||
"Username": "Kate", | ||
"Gender": 1, | ||
"DateOfBirth": "1982-06-06", | ||
"Password": "password", | ||
"KnownAs": "Kate", | ||
"Created": "2017-04-08", | ||
"LastActive": "2017-04-08", | ||
"Introduction": "Qui elit nisi in aliquip Lorem minim qui deserunt exercitation minim laboris elit ex. Laboris officia laborum anim mollit aliquip sit cupidatat esse dolor non dolore. Adipisicing quis est ex nostrud laboris eu consectetur quis. Mollit esse sit nisi duis aliquip eu esse exercitation Lorem duis. Ut veniam aliqua id eu.\r\n", | ||
"LookingFor": 0, | ||
"Interests": "Deserunt eiusmod veniam veniam do et incididunt.", | ||
"City": "Westwood", | ||
"Country": "Palau", | ||
"Photos": [ | ||
{ | ||
"url": "https://randomuser.me/api/portraits/men/32.jpg", | ||
"isMain": true, | ||
"description": "Est quis ut do labore mollit qui proident ut proident aliqua voluptate dolor officia consequat." | ||
} | ||
] | ||
}, | ||
{ | ||
"Username": "Molly", | ||
"Gender": 1, | ||
"DateOfBirth": "1976-09-15", | ||
"Password": "password", | ||
"KnownAs": "Molly", | ||
"Created": "2017-06-05", | ||
"LastActive": "2017-06-05", | ||
"Introduction": "Aute cillum adipisicing irure non consequat labore. Reprehenderit fugiat eiusmod esse sit. Ullamco irure dolor consequat elit eiusmod pariatur. Officia voluptate commodo incididunt ullamco.\r\n", | ||
"LookingFor": 0, | ||
"Interests": "Proident incididunt eu ipsum sint anim aliquip id deserunt magna irure sint cillum.", | ||
"City": "Zarephath", | ||
"Country": "Jordan", | ||
"Photos": [ | ||
{ | ||
"url": "https://randomuser.me/api/portraits/men/13.jpg", | ||
"isMain": true, | ||
"description": "Elit consequat culpa ullamco eu nulla ullamco officia." | ||
} | ||
] | ||
}, | ||
{ | ||
"Username": "Amy", | ||
"Gender": 1, | ||
"DateOfBirth": "1996-08-08", | ||
"Password": "password", | ||
"KnownAs": "Amy", | ||
"Created": "2017-04-11", | ||
"LastActive": "2017-04-11", | ||
"Introduction": "Incididunt quis occaecat deserunt magna et. Laborum eu veniam cupidatat magna id excepteur. Cupidatat exercitation officia dolore tempor pariatur. Dolor occaecat ipsum quis quis excepteur qui quis aliquip deserunt exercitation cupidatat ea ex commodo. Elit culpa duis pariatur culpa aliquip. Pariatur laboris duis ad occaecat voluptate aliquip enim dolore ea dolore. Laborum elit sit nulla ut pariatur occaecat.\r\n", | ||
"LookingFor": 0, | ||
"Interests": "Dolor voluptate ad veniam anim quis non laborum pariatur fugiat duis aliquip nisi.", | ||
"City": "Wiscon", | ||
"Country": "Cook Islands", | ||
"Photos": [ | ||
{ | ||
"url": "https://randomuser.me/api/portraits/men/57.jpg", | ||
"isMain": true, | ||
"description": "Incididunt aliqua mollit incididunt voluptate." | ||
} | ||
] | ||
}, | ||
{ | ||
"Username": "Tereso", | ||
"Gender": 0, | ||
"DateOfBirth": "1951-05-26", | ||
"Password": "password", | ||
"KnownAs": "Tereso", | ||
"Created": "2017-05-08", | ||
"LastActive": "2017-05-08", | ||
"Introduction": "Proident tempor ut consectetur cupidatat incididunt consectetur velit dolor enim sint exercitation nisi ex enim. Minim quis cupidatat minim et elit magna duis ea labore anim eu dolore consequat. Voluptate aute quis dolor incididunt duis consectetur magna pariatur eiusmod. Ea cillum id mollit est amet consectetur nisi do. Exercitation eiusmod fugiat elit deserunt. Nisi dolore cillum consequat aliquip voluptate esse eu.\r\n", | ||
"LookingFor": 1, | ||
"Interests": "Est veniam eu in culpa nostrud proident elit exercitation Lorem amet sit sit.", | ||
"City": "Wollochet", | ||
"Country": "Paraguay", | ||
"Photos": [ | ||
{ | ||
"url": "https://randomuser.me/api/portraits/men/2.jpg", | ||
"isMain": true, | ||
"description": "Id ut consequat labore ex laboris laborum aliqua commodo aliqua nisi incididunt irure sit." | ||
} | ||
] | ||
}, | ||
{ | ||
"Username": "Cryder", | ||
"Gender": 0, | ||
"DateOfBirth": "1968-01-14", | ||
"Password": "password", | ||
"KnownAs": "Cryder", | ||
"Created": "2017-08-13", | ||
"LastActive": "2017-08-13", | ||
"Introduction": "Dolor minim exercitation velit minim. Eu mollit nisi aliqua cillum laboris ipsum ad magna sit qui aliqua minim est occaecat. Minim duis reprehenderit aliqua quis cillum nisi duis culpa sunt. Amet tempor tempor eu esse cupidatat aute elit aute. Deserunt cupidatat sit elit et ullamco. Incididunt velit ipsum dolore cillum.\r\n", | ||
"LookingFor": 1, | ||
"Interests": "Amet proident aliquip velit excepteur non et.", | ||
"City": "Bluetown", | ||
"Country": "Falkland Islands (Malvinas)", | ||
"Photos": [ | ||
{ | ||
"url": "https://randomuser.me/api/portraits/men/26.jpg", | ||
"isMain": true, | ||
"description": "Ad ad cupidatat aliqua enim officia aute reprehenderit sint veniam aute laborum reprehenderit." | ||
} | ||
] | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters