private async Task SeedData(AuctionDbContext context)
 {
     context.Cities.Add(GetDummyCity());
     context.AuctionHouses.Add(GetDummyAuctionHouse());
     context.AddRange(GetDummyData());
     await context.SaveChangesAsync();
 }
示例#2
0
        private void InitSQL(string name, string location)
        {
            string           filePath = Path.Combine(location, string.Format("{0}.{1}", name, "mdf"));
            AuctionDbContext db       = new AuctionDbContext(_folderMVC, filePath);

            db.Initial();
        }
 private async Task SeedData(AuctionDbContext context)
 {
     context.Users.Add(SeedUser());
     context.AddRange(GetDummyData());
     context.AddRange(GetDummyReceipts());
     await context.SaveChangesAsync();
 }
        public void SeedAdminRole(AuctionDbContext context)
        {
            var store = new RoleStore<IdentityRole>(context);
            var manager = new RoleManager<IdentityRole>(store);
            var role = new IdentityRole { Name = "Admin" };

            manager.Create(role);
        }
示例#5
0
 public HomeController(AuctionDbContext _db)
 {
     db       = _db;
     layoutVM = new LayoutViewModel()
     {
         CategoriesVM = RecursiveMenu.GetRecursiveMenu(db)
     };
 }
示例#6
0
 public TraderManager(
     UserManager <ApplicationUser> userManager,
     RoleManager <IdentityRole> roleManager,
     AuctionDbContext dbContext)
 {
     _userManager = userManager;
     _roleManager = roleManager;
     _dbContext   = dbContext;
 }
示例#7
0
 public ItemController(AuctionDbContext _db, IWebHostEnvironment hostEnvironment)
 {
     db = _db;
     webHostEnvironment = hostEnvironment;
     layoutVM           = new LayoutViewModel()
     {
         CategoriesVM = RecursiveMenu.GetRecursiveMenu(db)
     };
 }
示例#8
0
        public void GetCarFromDBTest()
        {
            //Arrange
            var            context = new AuctionDbContext("DefaultConnection");
            var            db      = context;
            CarsRepository tmp     = new CarsRepository(context);

            Assert.AreEqual(tmp.GetAll(), db.Cars);
        }
示例#9
0
        public void GetAllUnCheckedFromDBTest()
        {
            //Arrange
            var            context = new AuctionDbContext("DefaultConnection");
            var            db      = context;
            CarsRepository tmp     = new CarsRepository(context);
            var            target  = db.Cars.Where(item => item.IsCheck == false);

            Assert.IsNotNull(target);
        }
示例#10
0
        public void GetAllSedansFromDBTest()
        {
            //Arrange
            var            context = new AuctionDbContext("DefaultConnection");
            var            db      = context;
            CarsRepository tmp     = new CarsRepository(context);
            var            target  = db.Cars.Where(item => item.CategoryId == 1);

            Assert.IsNotNull(target);
        }
示例#11
0
 public ItemService(AuctionDbContext context,
                    ICloudinaryService cloudinaryService,
                    IUserService userService,
                    IReceiptService receiptService)
 {
     this.context           = context;
     this.cloudinaryService = cloudinaryService;
     this.userService       = userService;
     this.receiptService    = receiptService;
 }
 public AccountController(IConfiguration _configuration,
                          AuctionDbContext _db, ILogger <AccountController> logger, IHttpContextAccessor httpContextAccessor, IWebHostEnvironment hostEnvironment)
 {
     _logger              = logger;
     webHostEnvironment   = hostEnvironment;
     _httpContextAccessor = httpContextAccessor;
     db            = _db;
     configuration = _configuration;
     layoutVM      = new LayoutViewModel()
     {
         CategoriesVM = RecursiveMenu.GetRecursiveMenu(db)
     };
 }
        public void SeedUsers(AuctionDbContext context)
        {
            var store = new UserStore<User>(context);
            var manager = new UserManager<User>(store);

            User admin = new User
            {
                UserName = "******",
                Email = "*****@*****.**",
                FirstName = "Tosho",
                LastName = "Ivanov",
                PhoneNumber = "+3591234569",
                SecurityStamp = Guid.NewGuid().ToString(),
                PasswordHash = this.hasher.HashPassword("1"),
            };

            User pesho = new User
            {
                UserName = "******",
                Email = "*****@*****.**",
                FirstName = "Pesho",
                LastName = "Goshov",
                PhoneNumber = "+3591234567",
                SecurityStamp = Guid.NewGuid().ToString(),
                PasswordHash = this.hasher.HashPassword("1"),
            };

            User gosho = new User
            {
                UserName = "******",
                Email = "*****@*****.**",
                FirstName = "Gosho",
                LastName = "Toshov",
                PhoneNumber = "+3591234568",
                SecurityStamp = Guid.NewGuid().ToString(),
                PasswordHash = this.hasher.HashPassword("1"),
            };

            this.Users.Add(pesho);
            this.Users.Add(gosho);
            this.Users.Add(admin);
            context.Users.AddOrUpdate(this.Users.ToArray());
            context.SaveChanges();

            var adminId = context.Users.FirstOrDefault(u => u.UserName == "*****@*****.**").Id;
            manager.AddToRole(adminId, "Admin");
            context.SaveChanges();
        }
示例#14
0
 public UnitOfWork(
     AuctionDbContext dbContext,
     IBidRepo bidRepo,
     ICategoryRepo categoryRepo,
     IItemRepo itemRepo,
     IOrderRepo orderRepo,
     IPaymentRepo paymentRepo
     )
 {
     _dbContext    = dbContext;
     _bidRepo      = bidRepo;
     _categoryRepo = categoryRepo;
     _itemRepo     = itemRepo;
     _orderRepo    = orderRepo;
     _paymentRepo  = paymentRepo;
 }
示例#15
0
        public static List <CategoryVM> GetRecursiveMenu(AuctionDbContext db)
        {
            //Recursive
            List <Category> category   = new List <Category>();
            List <Category> categories = db.Categories.OrderByDescending(c => c.Children.Any()).ToList();

            category = categories
                       .Where(c => c.ParentId == null)
                       .Select(c => new Category()
            {
                Id       = c.Id,
                Name     = c.Name,
                ParentId = c.ParentId,
                Children = GetChildren(categories, c.Id)
            }).ToList();

            return(CategoryUtility.MapModelsToVMs(category));
        }
        public void SeedItems(AuctionDbContext context)
        {
            Array enumValuesArray = Enum.GetValues(typeof(ItemType));

            for (var i = 0; i < 10; i++)
            {
                var rand = this.random.Next(0, 7);
                var item = new Item
                {
                    Title = string.Format("Item {0}", i),
                    Author = string.Format("Pablo{0} Picasso{1}", i, i),
                    Description = "Description" + i,
                    Type = (ItemType)enumValuesArray.GetValue(rand)
                };

                this.Items.Add(item);
            }

            context.Items.AddOrUpdate(this.Items.ToArray());
            context.SaveChanges();
        }
示例#17
0
 public NotifiedExpiredItemController(AuctionDbContext _db)
 {
     db = _db;
 }
示例#18
0
 public OrderRepo(AuctionDbContext db) : base(db)
 {
 }
示例#19
0
 public BidRepo(AuctionDbContext db) : base(db)
 {
 }
 public Startup()
 {
     this.db = new AuctionDbContext();
 }
示例#21
0
 public UserService(AuctionDbContext context)
 {
     this.context = context;
 }
        public void SeedAuctions(AuctionDbContext context)
        {
            for (var i = 0; i < 10; i++)
            {
                var randUser = this.random.Next(0, 3);
                var items = new List<Item> { this.Items[i] };
                var bidders = this.Users;

                var auction = new Auction
                {
                    Name = "Auction " + i,
                    DateOfAuction = DateTime.UtcNow.AddHours(24 + (24 * i)),
                    Active = false,
                    InitialPrice = 10000 + 1000 * i,
                    BidStep = 500,
                    Items = items,
                    //Creator = this.Users[randUser],
                    Bidders = bidders
                };
                this.Auctions.Add(auction);
            }

            context.Auctions.AddOrUpdate(this.Auctions.ToArray());
            context.SaveChanges();
        }
示例#23
0
 public UnitOfWork(AuctionDbContext db)
 {
     _db = db;
 }
 public AuctionRoom(IBidsServices bidService)
 {
     this.bids = bidService;
     this.db = new AuctionDbContext();
 }
示例#25
0
 public ArtworksRepository(AuctionDbContext context)
 {
     _context = context;
 }
示例#26
0
 public UserRepository(AuctionDbContext db)
 {
     _db = db;
 }
示例#27
0
 public PaymentRepo(AuctionDbContext db) : base(db)
 {
 }
示例#28
0
 public CategoryRepo(AuctionDbContext db) : base(db)
 {
 }
 public OffersRepository(AuctionDbContext context)
 {
     _context = context;
 }
示例#30
0
 public BidService(AuctionDbContext context, IUserService userService)
 {
     this.context     = context;
     this.userService = userService;
 }
示例#31
0
 public CategoryRepository(AuctionDbContext db)
 {
     _db = db;
 }
示例#32
0
 public ArtWorksController(AuctionDbContext context, IHostingEnvironment hostingEnvironment)
 {
     _context = context;
     this.hostingEnvironment = hostingEnvironment;
 }
示例#33
0
 public AuctionService(AuctionDbContext context, IHttpContextAccessor httpContextAccessor) : base(context, httpContextAccessor)
 {
 }
示例#34
0
 public ReceiptService(AuctionDbContext context)
 {
     this.context = context;
 }
示例#35
0
 public AuctionRepository(AuctionDbContext context) : base(context)
 {
 }
示例#36
0
 public BidController(AuctionDbContext _db)
 {
     db = _db;
 }