Пример #1
0
        public static void Initialize(CakelistContext cakelistContext)
        {
            cakelistContext.Database.EnsureCreated();

            // Seed user data
            if (cakelistContext.Users.Any())
            {
                return; // Database has already Users
            }

            var users = new User[]
            {
                new User {
                    FirstName = "Tony", LastName = "Stark", Email = "*****@*****.**"
                },
                new User {
                    FirstName = "Steven", LastName = "Rogers", Email = "*****@*****.**"
                },
                new User {
                    FirstName = "Bruce", LastName = "Banner", Email = "*****@*****.**"
                }
            };

            foreach (User user in users)
            {
                cakelistContext.Users.Add(user);
            }

            cakelistContext.SaveChanges();

            // Seed request data

            if (cakelistContext.Requests.Any())
            {
                return;
            }
            ;

            var request = new CakeRequest {
                CreatedById = 1, AssignedToId = 2, Reason = "New shield"
            };

            request.AddVote(users[2]);

            cakelistContext.Requests.Add(request);

            cakelistContext.SaveChanges();
        }
Пример #2
0
 public UserRepository(ILogger <UserRepository> logger, CakelistContext cakelistContext)
 {
     _log             = logger;
     _cakelistContext = cakelistContext;
 }
Пример #3
0
 public CakeRequestRepository(ILogger <CakeRequestRepository> logger, CakelistContext cakelistContext)
 {
     _log             = logger;
     _cakelistContext = cakelistContext;
 }