コード例 #1
0
 public HomeController(IdentityAppContext context, ILogger <HomeController> logger)
 {
     _logger  = logger;
     _context = context;
 }
コード例 #2
0
 public ReportViewerController(IOptions <ApplicationSettings> appSettings
                               , IdentityAppContext context)
 {
     this.appSettings = appSettings.Value;
     this.context     = context;
 }
コード例 #3
0
 public UsersController(IdentityAppContext context)
 {
     _context = context;
 }
コード例 #4
0
 public AppUserRepository(IdentityAppContext context)
 {
     _context = context;
 }
コード例 #5
0
 public Repository(IdentityAppContext context)
 {
     _dbContext = context;
     _entity    = _dbContext.Set <TEntity>();
 }
コード例 #6
0
 public DashboardController(IdentityAppContext context, UserManager <AppUser> userManager, SignInManager <AppUser> signInManager)
 {
     _context       = context;
     _userManager   = userManager;
     _signInManager = signInManager;
 }
コード例 #7
0
 public ProductsController(IdentityAppContext context)
 {
     _context = context;
 }
コード例 #8
0
        public static void Initialize(IServiceProvider serviceProvider)
        {
            var context = new IdentityAppContext(serviceProvider.GetRequiredService <DbContextOptions <IdentityAppContext> >());

            context.Database.EnsureDeleted();
            context.Database.Migrate();

            var user = new User
            {
                FirstName     = "Test",
                LastName      = "User",
                Password      = "******",
                StreetAdress  = "Gogubbegatan 3",
                PostNumber    = "41706",
                City          = "Gothenburg",
                Country       = "Sweden",
                Email         = "*****@*****.**",
                Currency      = "SEK",
                PhoneNumber   = "0700000000",
                SecurityStamp = Guid.NewGuid().ToString(),
                UserName      = "******"
            };
            var passwordHasher = new PasswordHasher <User>();

            user.PasswordHash = passwordHasher.HashPassword(user, "!1Aaaa");
            var manager = serviceProvider.GetRequiredService <UserManager <User> >();

            manager.CreateAsync(user).Wait();
            var roleManager = serviceProvider.GetRequiredService <RoleManager <AppRole> >();
            var result      = roleManager.CreateAsync(new AppRole {
                Name = "KeyCustomer", NormalizedName = "KEYCUSTOMER", RoleName = "KeyCustomer"
            }).Result;
            var products = new List <Product> {
                new Product
                {
                    Name        = "Air Jordans",
                    Price       = 199,
                    Image       = ReadFile("Images/airJordans.jpg"),
                    Description = "Fly high like Michael",
                    Category    = "sport",
                    CreatedAt   = DateTime.Today
                },
                new Product
                {
                    Name        = "Nike Air Zoom",
                    Price       = 99,
                    Image       = ReadFile("Images/NikeAirZoom.jpg"),
                    Description = "Zoom like the nikon 500",
                    Category    = "sport",
                    CreatedAt   = DateTime.Today
                },
                new Product
                {
                    Name        = "Nike Mercurial Vapor",
                    Price       = 150,
                    Image       = ReadFile("Images/NikeMercurialVapor.jpg"),
                    Description = "Play Ball like Messi",
                    Category    = "sport",
                    CreatedAt   = DateTime.Today
                },
                new Product
                {
                    Name        = "Moon Boots",
                    Price       = 299,
                    Image       = ReadFile("Images/moonboot.jpg"),
                    Description = "Perfect for netflix and fake the moon landing",
                    Category    = "Space Exploration",
                    CreatedAt   = DateTime.Today
                },
                new Product
                {
                    Name        = "Pimp shoe Fish-tank edt",
                    Price       = 100,
                    Image       = ReadFile("Images/pimpshoe.jpg"),
                    Description = "When Paolo comes a knocking better have shoes with style",
                    Category    = "Playah",
                    CreatedAt   = DateTime.Today
                },
                new Product
                {
                    Name        = "Croc-Martens",
                    Price       = 999,
                    Image       = ReadFile("Images/croc-martens.jpg"),
                    Description = "The perfect shoe for the casual emo",
                    Category    = "Casual",
                    CreatedAt   = DateTime.Today
                },
                new Product
                {
                    Name        = "Clown Shoes",
                    Price       = 1,
                    Image       = ReadFile("Images/clownshoes.jpg"),
                    Description = "When Insane Clown Posse is your life, strut your stuff with these flippin clown shoes",
                    Category    = "Juggalo",
                    CreatedAt   = DateTime.Today
                }
            };

            var order = new Order
            {
                User           = context.Users.FirstOrDefault(),
                PaymentOption  = "Swish",
                TotalAmount    = 300,
                DeliveryOption = "2-5 days"
            };

            var orderItems = new List <OrderItem>();

            products.ForEach(product => {
                orderItems.Add(
                    new OrderItem
                {
                    Order    = order,
                    Product  = product,
                    Quantity = 1
                });
            });
            context.OrderItems.AddRange(orderItems);

            var currencyRates = CurrencyManager.GetCurrencyRates().Result;

            foreach (KeyValuePair <string, double> item in  currencyRates.Rates)
            {
                context.Currencies.Add(new Currency
                {
                    CurrencyCode = item.Key,
                    CurrencyRate = item.Value,
                    LastUpdated  = DateTimeOffset.UtcNow
                });
            }
            context.SaveChanges();
            context.Dispose();
        }
コード例 #9
0
 public OrderConfirmationController(IdentityAppContext context, IConfiguration config, UserManager <User> userMgr)
 {
     _context = context;
     _config  = config;
     UserMgr  = userMgr;
 }
コード例 #10
0
 public SubJobCategoriesController(IdentityAppContext db)
 {
     _db = db;
 }
コード例 #11
0
 public UserProjectRepository(IdentityAppContext context)
 {
     _context = context;
 }
コード例 #12
0
 public UserLogsController(IdentityAppContext context)
 {
     this.context = context;
 }
コード例 #13
0
        public PostController(IdentityAppContext context, UserManager <AppUser> userManager)
        {
            _context = context;

            _userManager = userManager;
        }