Пример #1
0
 public PersonRepository(BookingDbContext context)
 {
     _context = context;
 }
Пример #2
0
        public void Initialize(BookingDbContext _context)
        {
            _context.Database.EnsureCreated();

            if (_context.Persons.Any(r => r.Name != null))
            {
                return;
            }

            string userName = "******";

            var hash = SecurePasswordHasher.Hash("test123");

            _context.Persons.Add(new Person()
            {
                Name = userName, Password = hash, Email = "*****@*****.**"
            });

            _context.SaveChanges();

            Person person = _context.Persons.FirstOrDefault(u => u.Name == userName);

            DateTime date = DateTime.Parse("2018-07-11");

            _context.Bookings.Add(new Booking()
            {
                Person = person, Date = date, Time = "11.00-14.00"
            });

            _context.SaveChanges();

            userName = "******";

            _context.Persons.Add(new Person()
            {
                Name = userName, Password = hash, Email = "*****@*****.**"
            });

            _context.SaveChanges();

            person = _context.Persons.FirstOrDefault(u => u.Name == userName);

            date = DateTime.Parse("2018-07-12");
            _context.Bookings.Add(new Booking()
            {
                Person = person, Date = date, Time = "11.00-14.00"
            });

            _context.SaveChanges();

            userName = "******";

            _context.Persons.Add(new Person()
            {
                Name = userName, Password = hash, Email = "*****@*****.**"
            });

            _context.SaveChanges();

            person = _context.Persons.FirstOrDefault(u => u.Name == userName);

            date = DateTime.Parse("2018-07-13");
            _context.Bookings.Add(new Booking()
            {
                Person = person, Date = date, Time = "11.00-14.00"
            });

            _context.SaveChanges();

            // MoneyAccount money = _context.MoneyAccounts.FirstOrDefault(u => u.Id == card.Id);

            // _context.Balances.Add(new Balance() { Id = money.Id, Ammount = 88.99, Currency = "kr" });// pungetn i ammount kan behöva var ,
            //_context.SaveChanges();
        }
Пример #3
0
 public BookingRepository(BookingDbContext context)
 {
     _context = context;
 }